如何从 Unix 时间戳计算本地时间

如何从 Unix 时间戳计算本地时间

问题描述:

如果全世界的 Unix 时间戳都相同,我如何才能获得本地时间.

If unix timestamp is the same across the world how is am I able to get local time.

或者是基于不同的时区时间戳不同.即我在美国,从 UTC 1970 开始的当前秒数是 5,000,但如果我在亚洲并检查时间戳,它将是 4,000 秒?

Or is it based on the different timezones the timestamp is different. i.e. I am in US the current seconds from UTC 1970 is 5,000 but if I am in Asia and check timestamp it will be 4,000 seconds ?

UTC 在世界上每个国家都是一样的,无论你在美国还是在亚洲,这个值都是一样的.

UTC is the same for every country in the world, whether you check in the US or in Asia the value will be the same.

本地时间是通过使用时区偏移量计算的(通常通过 IANA 时区数据库提供一>).将其添加到 UTC 时间以确定自 1970 年以来的本地时间".

Local time is calculated by using a time-zone offset (usually provided through the IANA time zone database). This is added to UTC time to determine the "Local Time" since 1970.