Skip to content

Instantly share code, notes, and snippets.

@bobgodwinx
Last active October 26, 2015 14:07
Show Gist options
  • Save bobgodwinx/bde232c373f90ed71ce1 to your computer and use it in GitHub Desktop.
Save bobgodwinx/bde232c373f90ed71ce1 to your computer and use it in GitHub Desktop.
lazy var dateFormatter:NSDateFormatter = {
var dateFormatter:NSDateFormatter?
var __dispatchToken: dispatch_once_t = 0
dispatch_once(&__dispatchToken) {
dateFormatter = NSDateFormatter()
/**
setting the default locale to Germany // for USA use us_US
*/
dateFormatter?.locale = NSLocale(localeIdentifier: "de_DE")
/**
set date style as you want
*/
dateFormatter?.dateStyle = .ShortStyle;
dateFormatter?.timeStyle = .ShortStyle;
/**
UTC DateStrings e.g. 2015-08-28T09:07:50
dateFormatter?.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
UTC DataString e.g 2015-04-17T13:30:00+02:00
dateFormater?.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ"
*/
}
return dateFormatter!
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment