【问题标题】:Python JS current timePython JS 当前时间
【发布时间】:2020-11-20 13:09:47
【问题描述】:

Python

import time
round(time.time()*1000)

JS

new Date().getTime()

这两个时区是否相同或取决于本地时区 (as mentioned here)?我得到了几乎相同的结果(在控制台和 IDE 中手动测试)。但不知道,如果我的时区改变,结果是否会改变。

【问题讨论】:

    标签: javascript python time gettime


    【解决方案1】:

    从 python 的时间库 https://docs.python.org/3/library/time.html 的文档中,python 的 time.time() 返回 1970 年 1 月 1 日的浮点数,而 JS getTime() 返回 1970 年 1 月 1 日的时间。两者的输出将有所不同,但你可以通过转换它从 python 中获得与 JS 相同的值,在你的情况下你已经完成了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 2017-11-18
      • 2019-07-08
      • 1970-01-01
      相关资源
      最近更新 更多