为什么 time.asctime(time.gmtime()) 忽略 GMT?
why time.asctime(time.gmtime()) ignores GMT?
我想获取当前时间并使用
from time import *
asctime(gmtime())
为此。
但是,我得到的是 GMT+0 时间,而不是我的当地时间 GMT+3:
...$ 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
...$
如何在不手动更改从 gmtime()
返回的元组的情况下将时间调整为我的本地时间?
https://docs.python.org/3/library/time.html#time.localtime
time.localtime([secs])
Like gmtime() but converts to local time. If
secs is not provided or None, the current time as returned by time()
is used. The dst flag is set to 1 when DST applies to the given time.
我想获取当前时间并使用
from time import *
asctime(gmtime())
为此。
但是,我得到的是 GMT+0 时间,而不是我的当地时间 GMT+3:
...$ 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
...$
如何在不手动更改从 gmtime()
返回的元组的情况下将时间调整为我的本地时间?
https://docs.python.org/3/library/time.html#time.localtime
time.localtime([secs])
Like gmtime() but converts to local time. If secs is not provided or None, the current time as returned by time() is used. The dst flag is set to 1 when DST applies to the given time.