Linux上Swift中的NSDateFormatter
我有一个密码:Linux上Swift中的NSDateFormatter,swift,nsdateformatter,foundation,Swift,Nsdateformatter,Foundation,我有一个密码: import Foundation let date = NSDate() let formatter = NSDateFormatter(); formatter.locale = NSLocale.currentLocale() formatter.dateStyle = NSDateFormatterStyle.MediumStyle formatter.timeStyle = NSDateFormatterStyle.MediumStyle formatter.dat
import Foundation
let date = NSDate()
let formatter = NSDateFormatter();
formatter.locale = NSLocale.currentLocale()
formatter.dateStyle = NSDateFormatterStyle.MediumStyle
formatter.timeStyle = NSDateFormatterStyle.MediumStyle
formatter.dateFormat = "HH:mm"
print(formatter.stringFromDate(date))
在Mac all fine works中,我只看到了时区中HH:mm格式的当前时间,但在Linux dateFormat不工作的情况下,我看到“2016年1月3日,10:56:21 PM”这是UTC时间 如果删除
dateStyle
和timeStyle
,会发生什么?如果删除dateStyle
和timeStyle
函数formatter.stringFromDate(date)
在Linux上返回的字符串为空。似乎已经报告了错误:谢谢!我找不到苹果的bug追踪器…结果:“晚上11:47:43”