【发布时间】:2016-05-12 20:12:56
【问题描述】:
func date() -> String {
return NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: NSDateFormatterStyle.ShortStyle, timeStyle: NSDateFormatterStyle.MediumStyle)
}
var date = date() // 2016. 5. 13. 오전 4:45:16
以上代码,date每次调用date()时获取韩国当前日期值
我希望从 NSDate() 中刷新新值,因此将刷新新值插入到下面代码中的变量中
var yearMonDay = "2016. 5. 13"
var hourMinSec = "오전 4:45:16"
hmmm 有没有办法将 NSDate() 分成如下代码的片段?
yearMonDay = NSDate().?? // refresh date "year: month: day"
hourMinSec = NSDate().?? // refresh date "am/fm hour:minute:second
【问题讨论】:
-
考虑重新表述问题。用 NSDateComponents 实现的不是你想要的吗?
标签: swift nsdate nsdatecomponents