[英]Getting timezone name like abbreviation in Swift
Note: GMT does not represent timezone for Asia/Kolkata. 注意:格林尼治标准时间不代表亚洲/加尔各答的时区。 (It should give you IST) You should check your device/simulator time zone settings.
(应该给您IST)。您应该检查设备/模拟器的时区设置。 If you are testing simulator then check your (mac) system time zone.
如果要测试模拟器,请检查(mac)系统时区。
Your snapshot indicates - you are trying with Playground editor. 您的快照表明-您正在尝试使用Playground编辑器。 Try to set location/time zone for your Mac system.
尝试为Mac系统设置位置/时区。
Mac System ► (Go to) System Preference ► Date Time ► Time Zone (Here you can see your system time zone)
Mac系统►(转到)系统偏好设置►日期时间►时区(在这里您可以看到系统时区)
I tried following code with given results for IST/India: 我尝试使用以下代码为IST / India提供给定的结果:
print("**> TimeZone.current.identifier - \(TimeZone.current.identifier)\n")
// TimeZone.current.identifier - Asia/Kolkata
print("**> TimeZone.current.description - \(TimeZone.current.description)\n")
// TimeZone.current.description - Asia/Kolkata (current)
print("**> TimeZone.current.debugDescription - \(TimeZone.current.debugDescription)\n")
// TimeZone.current.debugDescription - Asia/Kolkata (current)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.