Kev*_*vin 3 python time timezone datetime
如果我想转换时区,通常我会执行以下操作
# local interpreted as pst to utc
utc = pytz.utc
pst = pytz.timezone('America/Los_Angeles')
start_time_str = time.strftime('%Y-%m-%d %H:%M:%S', \
time.localtime(start_time))
start_time_datetime = \
datetime.datetime.strptime(start_time_str, "%Y-%m-%d %H:%M:%S")
start_time_datetime = \
start_time_datetime.replace(tzinfo=pst).astimezone(utc)
Run Code Online (Sandbox Code Playgroud)
现在我想做类似的事情,比如我想将本地时间转换为 pst
localtime = datetime.datetime.fromtimestamp(time.mktime(
time.localtime()))
Run Code Online (Sandbox Code Playgroud)
我不太确定你将如何实现这一目标
任何帮助,将不胜感激
| 归档时间: |
|
| 查看次数: |
14389 次 |
| 最近记录: |