关于云函数上时间戳换日期的问题。手机跟电脑测试居然不一致?

小程序 文章 2022-04-20 09:20 439 0 全屏看文

AI助手支持GPT4.0

关于云函数上时间戳换日期的问题。手机跟电脑测试居然不一致?Regarding the issue of changing timestamps to dates on cloud functions. Is the test on the mobile phone and the computer actually inconsistent?

关于云函数上时间戳换日期的问题。手机跟电脑测试居然不一致?

问题是这样的,同一个云函数,手机上调用,跟电脑上调用,返回的日期居然相差一天。

直接上图,各位看看是怎么回事。。。。

这个是代码

这个是电脑上调用结果

1650394920461

这个是手机测试 日志结果

1650394552861

我希望有大佬可以给我解惑,看是我什么地方理解错了。。。

The problem is that the return date of the same cloud function called on the mobile phone is one day different from that called on the computer. Go straight to the above picture and see what's going on.... This is the code, this is the result of the call on the computer 1650394920461, this is the result of the mobile phone test log 1650394552861, I hope someone can solve my doubts and see what I misunderstood...

回答:

Mr.Zhao:

时区不一样

brave:

云函数中的时区为 UTC+0,不是 UTC+8,在云函数中使用时间时需特别注意。如果需要默认 UTC+8,可以配置函数的环境变量,设置 TZ 为 Asia/Shanghai



天天开心:

配置时区

文档搜TZ


-EOF-

AI助手支持GPT4.0