from datetime import datetime, timedelta, timezone
print(datetime.now())
mydate = datetime(2018, 11, 11, 20, 00)
print(mydate)
print(mydate.timestamp())
mytimeStamp = 1519637291.0
print(datetime.fromtimestamp(mytimeStamp))
print(datetime.utcfromtimestamp(mytimeStamp))
cday = datetime.strptime('2015-6-1 18:19:59', '%Y-%m-%d %H:%M:%S')
print(cday)
print(datetime.now().strftime('%a, %b %d %H:%M'))
date = datetime(2018, 11, 11, 20, 00)
print(date + timedelta(hours=10))
print(date - timedelta(days=1))
print(date + timedelta(days=1, hours=2))
tz_utc_8 = timezone(timedelta(hours=8))
print(datetime.now().replace(tzinfo=tz_utc_8))
bj_dt = datetime.now().replace(tzinfo=tz_utc_8)
print("基准时区", bj_dt)
bj_dt = bj_dt.astimezone(timezone(timedelta(hours=8)))
print("北京时区", bj_dt)
tokyo_dt = bj_dt.astimezone(timezone(timedelta(hours=9)))
print("东京时区", tokyo_dt)