NSDate References
NSDate
NSDateFormatter
NSDateComponents
NSDateComponentFormatter
NSCalendar
String與NSDate相互轉(zhuǎn)換
獲取當(dāng)前系統(tǒng)時間:
let currentDate = NSDate()
打印輸出:
初始化NSDateFormatter
dateFormatter.locale = NSLocale.currentLocale()
配置不同local identifier
dateFormatter.locale = NSLocale(localeIdentifier: "el_GR" ) //french dateFormatter.locale = NSLocale(localeIdentifier: "fr_FR") //greek
配置不同的NSDate輸出格式
and short style
dateFormatter.dateStyle = NSDateFormatterStyle.ShortStyle convertedDate = dateFormatter.stringFromDate(currentDate)
配合不同的local identifier