如何从 Unix 时间戳计算本地时间 [英] How is local time calculated from Unix timestamp

查看:52
本文介绍了如何从 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.

这篇关于如何从 Unix 时间戳计算本地时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆