[英]Get local time reflected on PC and not other time zone
I am using python v3.6 to get current time. 我正在使用python v3.6获取当前时间。
import time
current_time = time.strftime("%H:%M:%S %Y-%m-%d", time.gmtime())
The code works but the time retrieved is from some other time zones. 该代码可以工作,但是检索到的时间是在其他一些时区中。 How do I retrieve time that is the same as reflected on the Windows 10 clock on my PC?
如何获取与PC上Windows 10时钟上反映的时间相同的时间?
Try the below. 请尝试以下。 I expect gmtime is for GMT(UTC more likely), vs local.
我希望gmtime是GMT(更有可能是UTC),而不是本地。 See https://docs.python.org/2/library/time.html
参见https://docs.python.org/2/library/time.html
>>> time.strftime("%H:%M:%S %Y-%m-%d", time.gmtime())
'03:16:00 2017-08-20'
>>> time.strftime("%H:%M:%S %Y-%m-%d", time.localtime())
'13:16:08 2017-08-20
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.