在所有平台上获取全球UTC时间戳
我正在尝试在客户端和Python的服务器端为我的程序提供当前的时间戳。但是,我的朋友们和我自己在一起都有问题。我已经尝试过两次同步,并尝试了许多不同的方法来将当前时间作为全球同步的UTC。
这是我尝试的,结果无效。
导入DateTime dateTime.dateTime.utcnow().timestamp()
导入箭头 arrow.now()。时间戳()
导入时间 time.time()
来自DateTime Import DateTime,TimeDelta 进口时间 unixTime = time.mktime(dateTime.now())
来自DateTime Import DateTime 导入日历 d = dateTime.utcnow() unixTime = calendar.timegm(d.utctimetuple())
以及无数的方法。
I am trying to get the current timestamp for my program on both the client side, and the server side in python. However, my friends, along with myself, have problems. I have tried syncing both times, and tries numerous different methods to get the current time as UTC that is globally synced.
Here is what I've tried, with an invalid outcome.
import datetime datetime.datetime.utcnow().timestamp()
import arrow arrow.now().timestamp()
import time time.time()
from datetime import datetime, timedelta import time unixtime = time.mktime(datetime.now())
from datetime import datetime import calendar d = datetime.utcnow() unixtime = calendar.timegm(d.utctimetuple())
Along with countless more methods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论