仅使用 datetime 包将当前时间转换为 utc 时间 python
Convert current time to utc time python with only using datetime package
将 YYYY-MM-DD hh:mm:ss
格式的当前本地时间和日期转换为 Python
的 time
包中的 UTC 格式的最简单方法是什么?我正在使用以下方法获取当前时间:
import time
time.strftime("%Y") + "-" + time.strftime("%m") + "-" + time.strftime("%d") + " " + time.strftime("%H") + ":" + time.strftime("%M") + ":" + time.strftime("%S")
使用datetime.datetime
代替time
:
from datetime import datetime
time = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
将 YYYY-MM-DD hh:mm:ss
格式的当前本地时间和日期转换为 Python
的 time
包中的 UTC 格式的最简单方法是什么?我正在使用以下方法获取当前时间:
import time
time.strftime("%Y") + "-" + time.strftime("%m") + "-" + time.strftime("%d") + " " + time.strftime("%H") + ":" + time.strftime("%M") + ":" + time.strftime("%S")
使用datetime.datetime
代替time
:
from datetime import datetime
time = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")