通常情况下,如果我想转换时区,我的做法如下
# 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)
现在我想做类似的事情,比如我想把本地时间转换为pst
localtime = datetime.datetime.fromtimestamp(time.mktime(
time.localtime()))
我不太清楚你将如何实现这一点
希望得到任何帮助