How to get tomorrows date in Swift

1 Answer

0 votes
import Foundation

// Get today's date
let today = Date()

// Calculate tomorrow's date
if let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: today) {
    // Format and print tomorrow's date
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd"
    print("Tomorrow's date is: \(formatter.string(from: tomorrow))")
}



/*
run:

Tomorrow's date is: 2025-04-10

*/

 



answered Apr 9, 2025 by avibootz
...