我想获取我的当前时间并使用
id, token, createdAt, deletedAt, updatedAt
为此。
但是,我得到的是GMT + 0时间而不是我的当地时间GMT + 3:
from time import *
asctime(gmtime())
如何在不手动更改从...$ ipython
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
Type "copyright", "credits" or "license" for more information.
IPython 5.8.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from time import *; asctime(gmtime())
Out[1]: 'Tue Jul 2 12:02:06 2019'
In [2]:
Do you really want to exit ([y]/n)?
...$ date
Tue Jul 2 15:02:12 IDT 2019
...$
返回的元组的情况下将时间调整为我的本地时间?
答案 0 :(得分:1)
https://docs.python.org/3/library/time.html#time.localtime
time.localtime([秒])
类似于gmtime(),但转换为本地时间。如果 未提供secs或None,即time()返回的当前时间 用来。当DST应用于给定时间时,dst标志设置为1。