我是Swift 2的新手,并且习惯使用日期格式。
我的系统设置为“瑞士德语”,日期格式应为“ 25. Nov. 2015 19:25:56”
但是游乐场的结果侧边栏显示为“ 2015年11月25日,下午7:25”:日期格式为美式风格,上午/下午而非24小时格式。
我试过了
var myDate = NSDate()
print("date string:",myDate)
print(myDate.description) // no ouput
输出:
date string: 2015-11-25 18:21:58 +0000
2015-11-25 18:21:58 +0000
和
// How to check which locale Swift 2 is using?
我真的很感谢您的帮助!
谢谢罗兰
我不知道如何强制Playground环境使用您的语言环境,但是您可以在自己的代码中进行操作。
import Foundation
print(NSDate())
print(NSDate().descriptionWithLocale(NSLocale(localeIdentifier: "zh_TW")))
print(NSDate().descriptionWithLocale(NSLocale(localeIdentifier: "de_DE")))
...输出是...
2015-11-25 19:24:53 +0000
2015年11月25日 星期三 中歐標準時間 下午8:24:53
Mittwoch, 25. November 2015 um 20:24:53 Mitteleuropäische Normalzeit
...检查NSDateFormatter以获取更多信息
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句