gpt4 book ai didi

delphi - 为什么当我调用 UnixToDateTime 时会得到数千年后的结果?

转载 作者:行者123 更新时间:2023-12-03 15:23:19 26 4
gpt4 key购买 nike

我有以下时间戳: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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com