Search code examples
swiftdate

How we find out a next day in Swift


How do we find out a next day in Swift language? Suppose today is 2014-09-15. How we can find out a date: 2014-09-16.


Solution

  • Swift code without using NSCalendar:

    var today = NSDate()
    var res = today.dateByAddingTimeInterval(24*60*60)
    println("\(today), \(res)") // 2014-09-15 10:31:28 +0000, 2014-09-16 10:31:28 +0000