作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下时间戳:1444288186967
。
当我将其放入Epoch Converter时,我得到了正确的结果 08 Oct 2015 07:09:46。
但是,当我使用(如 another post 中提到的)函数 UnixToDateTime(const AValue: Int64): TDateTime
时,我得到02 Sep 47737 11:02:47。很奇怪,不是吗?
我的代码(使用 TMS Aurelius)
Person.EndDate.Value := UnixToDateTime(FHit.TimestampUntil);
其中 FHit.TimestampUntil
是一个 Int64
,正如 UnixToDateTime
函数所期望的那样。
Person.EndDate.Value
是一个 TMS Aurelius 可为空的 TDateTime
。
我怎么可能得到这样的日期结果?
最佳答案
通常 Unix 时间戳自 1970 年 1 月 1 日起以秒为单位。但是,值 1444288186967
以毫秒为单位。除以 1000 并四舍五入,您将得到预期的日期和时间 8.10.2015 7:09:47
i64 := round(1444288186967/1000);
dt := UnixToDateTime(i64);
Edit2.Text := DateTimeToStr(dt);
Edit2 显示 8.10.2015 7:09:47
关于delphi - 为什么当我调用 UnixToDateTime 时会得到数千年后的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33009090/
我有以下时间戳:1444288186967。 当我将其放入Epoch Converter时,我得到了正确的结果 08 Oct 2015 07:09:46。 但是,当我使用(如 another post
我是一名优秀的程序员,十分优秀!