Discuss / Python / 参考评论区

参考评论区

Topic source

ZugumZug

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

def to_timestamp(dt_str, tz_str):

    tz=int(tz_str[3:-3])

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

    tz_utc=timezone(timedelta(hours=tz))

    dt=cday.replace(tzinfo=tz_utc)

    return dt.timestamp()


  • 1

Reply