Discuss / Python / 本地转换

本地转换

Topic source

木马

#1 Created at ... [Delete] [Delete and Lock User]

def to_timestamp(dt_str,tz_str):

dt=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S')

tz=re.match(r'UTC([+-]\d+)\:00',tz_str)

bj_dt=dt+timedelta(hours=8-int(tz.group(1)))

return bj_dt.timestamp()


  • 1

Reply