Created
March 4, 2016 22:14
-
-
Save erikfloresq/d521194aa63ddc66e22a to your computer and use it in GitHub Desktop.
Format a date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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