Skip to content

Instantly share code, notes, and snippets.

@ahcode0919
Last active April 17, 2017 23:00
Show Gist options
  • Save ahcode0919/800079c7dde96c973a6e0b77715f0bf4 to your computer and use it in GitHub Desktop.
Save ahcode0919/800079c7dde96c973a6e0b77715f0bf4 to your computer and use it in GitHub Desktop.
Example of handling dates in Swift
let dateString = "09 Aug 2016 17:53:51 -0700"
let dateFormatter = NSDateFormatter()
// Good resource for date time format syntax
//http://userguide.icu-project.org/formatparse/datetime
dateFormatter.dateFormat = "dd MMM yyyy HH:mm:ss ZZZ"
let date = dateFormatter.dateFromString(dateString) //NSDate = "Aug 09, 2016, 5:53 PM"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment