Skip to content

Instantly share code, notes, and snippets.

@erikfloresq
Created March 4, 2016 22:14
Show Gist options
  • Save erikfloresq/d521194aa63ddc66e22a to your computer and use it in GitHub Desktop.
Save erikfloresq/d521194aa63ddc66e22a to your computer and use it in GitHub Desktop.
Format a date
class func getFormatterDate(dateString:String?)->String{
let dateFormater = NSDateFormatter()
dateFormater.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
//dateFormater.dateFormat = "dd MMMM yyyy"
dateFormater.timeZone = NSTimeZone(abbreviation: "GMT-05:00")
dateFormater.timeZone = NSTimeZone(name: "America/Lima")
let locale:NSLocale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormater.locale = locale
let date = dateFormater.dateFromString(dateString!)
let newDateFormat = NSDateFormatter()
newDateFormat.dateFormat = "dd/MM/yy HH:mm"
let newDateString:String = newDateFormat.stringFromDate(date!)
return newDateString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment