且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将Unix时间戳转换为日期时间

更新时间:2023-02-03 14:43:48

您的代码按原样工作正常。这是一个小提琴

Your code is working just fine, as is. Here is a fiddle.

每个告诉你的人使用 AddSeconds 是错误的。您提供给我们的数字显然以毫秒为单位。一年有31,536,000秒。 1415115303410除以31536000是4487。自1970年1月1日以来已经过去了4,487年。

Everyone that is telling you to use AddSeconds is wrong. The number you are giving us is clearly in milliseconds. There are 31,536,000 seconds in a year. 1415115303410 divided by 31536000 is 4487. There hasn't been 4,487 years passed since 1/1/1970.