Skip to content

Instantly share code, notes, and snippets.

@alexk1350
Last active August 29, 2015 14:08
Show Gist options
  • Save alexk1350/4f2f391867820f9760ef to your computer and use it in GitHub Desktop.
Save alexk1350/4f2f391867820f9760ef to your computer and use it in GitHub Desktop.
Swift Date Formatting
func getCurrentTime() -> String {
let currentDate = NSDate()
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "H"
var currentTime = dateFormatter.stringFromDate(date)
return currentTime
}
getCurrentTime()
//Additional Time Options
//y - year, d - day, m - month, E - weekday, a - AM or PM, h - hour, m -minute, s -second, z- timezone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment