Skip to content

Instantly share code, notes, and snippets.

@tonyedwardspz
Created August 4, 2015 10:16
Show Gist options
  • Save tonyedwardspz/9d9ecce60d4dd3aa26c8 to your computer and use it in GitHub Desktop.
Save tonyedwardspz/9d9ecce60d4dd3aa26c8 to your computer and use it in GitHub Desktop.
Swift Dates plyground
var date = NSDate()
var yesterday = date.dateByAddingTimeInterval(-24 * 60 * 60)
var dateComparisonResult: NSComparisonResult = date.compare(yesterday)
if dateComparisonResult == NSComparisonResult.OrderedAscending {
println("date is smaller than yesterday")
} else if dateComparisonResult == NSComparisonResult.OrderedDescending {
println("date is larger than yesterday")
} else {
println("Both dates are the smae")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment