[英]need to convert UTC time to current timezone of device
Im using this repo 我正在使用这个仓库
https://github.com/remirobert/Tempo https://github.com/remirobert/Tempo
Can someone help me understand how to grab the current time zone of the device, and then notify tempo? 有人可以帮助我了解如何获取设备的当前时区,然后通知速度吗? I am using the timeAgoNow() function of tempo to find display how long ago the post was made, but the timezone difference is messing it up.
我正在使用tempo的timeAgoNow()函数来查找显示发布该帖子的时间,但是时区差将其弄乱了。 My datasource is using UTC time.
我的数据源正在使用UTC时间。
Cocoa uses UTC internally. 可可在内部使用UTC。 for all of its date/time calculations.
用于其所有日期/时间计算。
If you create an NSDate for now: 如果您现在创建NSDate:
NSDate() NSDate()
You get a date that is the number of elapsed seconds since midnight, 1970 in UTC time. 您获得的日期是从UTC时间到1970年午夜以来经过的秒数。
Dates only have time zones when you display them. 日期仅在显示时区。
By default logging a date to the console logs it in UTC, which can be confusing. 默认情况下,将日期记录到控制台会将其记录为UTC,这可能会造成混淆。
If I'm working on a project that does a lot of date/time calculations I'll create a debugging method that converts an NSDate to a date/time string in the current locale, which is easier to read/debug without having to mentally convert from UTC back to local time. 如果我正在进行大量日期/时间计算的项目,则将创建一个调试方法,该方法将NSDate转换为当前语言环境中的日期/时间字符串,这样更易于阅读/调试,而无需费心从UTC转换回当地时间。
I have never used Tempo, so I don't know if it is using date strings, NSDate, or "internet dates" (which are also in UTC, but use a different "zero date" or "epoch date") 我从未使用过Tempo,所以我不知道它是否使用日期字符串,NSDate或“互联网日期”(这也是UTC,但使用不同的“零日期”或“时代”))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.