gpt4 book ai didi

java - 在Python中获取以毫秒为单位的GMT时间

转载 作者:行者123 更新时间:2023-12-02 11:07:35 25 4
gpt4 key购买 nike

尝试在Python中以毫秒为单位获取GMT,我可以用Java实现它,但需要Python的帮助。Java版本:

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
long time = cal.getTimeInMillis();
Sample output - 1528893731677

Python 版本:

millis = int(round(time.time() * 1000)) // How to get GMT time here?
Sample output - 1528953926983

最佳答案

from datetime import datetime
print(datetime.utcnow().timestamp() * 1000)

关于java - 在Python中获取以毫秒为单位的GMT时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50850212/

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