Discuss / Python / 20180527

20180527

Topic source

Gday小海狮

#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 = int(re.match(r'^(UTC)([+|-]\d{1,2})(:00)$',tz_str).group(2)) dt = dt + timedelta(hours=8-tz) return dt.timestamp()


  • 1

Reply