get current UTC datetime of Python
API
https://docs.python.org/3/library/datetime.html#datetime.datetime.now
now接口获取本地时间, tz不带表示当地时区, 带上可以指定特定时区。
utcnow获取世界协调时间
- classmethod
datetime.now(tz=None)Return the current local date and time.
If optional argument tz is
Noneor not specified, this is liketoday(), but, if possible, supplies more precision than can be gotten from going through atime.time()timestamp (for example, this may be possible on platforms supplying the Cgettimeofday()function).If tz is not
None, it must be an instance of atzinfosubclass, and the current date and time are converted to tz’s time zone.
Code
https://stackoverflow.com/questions/15940280/how-to-get-utc-time-in-python
法一
from datetime import datetime datetime.utcnow()
法二
from datetime import datetime,timezone now_utc = datetime.now(timezone.utc)
UTC
https://www.cnblogs.com/champyin/p/12767852.html
什么是UTC
UTC(Coodinated Universal Time),协调世界时,又称世界统一时间、世界标准时间、国际协调时间。由于英文(CUT)和法文(TUC)的缩写不同,作为妥协,简称UTC。
UTC 是现在全球通用的时间标准,全球各地都同意将各自的时间进行同步协调。UTC 时间是经过平均太阳时(以格林威治时间GMT为准)、地轴运动修正后的新时标以及以秒为单位的国际原子时所综合精算而成。
在军事中,协调世界时会使用“Z”来表示。又由于Z在无线电联络中使用“Zulu”作代称,协调世界时也会被称为"Zulu time"。
UTC 由两部分构成:
原子时间(TAI, International Atomic Time):
结合了全球400个所有的原子钟而得到的时间,它决定了我们每个人的钟表中,时间流动的速度。世界时间(UT, Universal Time):
也称天文时间,或太阳时,他的依据是地球的自转,我们用它来确定多少原子时,对应于一个地球日的时间长度。UTC的历史
1960年,国际无线电咨询委员会规范统一了 UTC 的概念,并在次年投入实际使用。
“Coordinated Universal Time”这个名字则在1967年才被正式采纳。
1967年以前, UTC被数次调整过,原因是要使用闰秒(leap second)来将 UTC 与地球自转时间进行统一。
CST
https://24timezones.com/shiqu/cst_china
CST (中国标准时间) 是UTC+8时区的知名名称之一,比UTC(协调世界时)提前8个小时与UTC的时间偏差可写为+08:00.
它被用作标准时间。

浙公网安备 33010602011771号