import time
print(time.time())
print(time.gmtime())
print(time.localtime())
t = time.localtime()
print(time.mktime(t))
print(time.strftime('%Y-%m-%d %H:%M:%S', t))
print(time.strftime('%Y-%m-%d %H:%M:%S'))
print(time.strptime('2017-06-26 22:58:29', '%Y-%m-%d %H:%M:%S'))
print(time.strptime('2017-06-26 22:58:29', '%Y-%m-%d %H:%M:%S'))
===========================================================
'''
%Y Year with century as a decimal number.
%m Month as a decimal number [01,12].
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%M Minute as a decimal number [00,59].
%S Second as a decimal number [00,61].
%z Time zone offset from UTC.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%I Hour (12-hour clock) as a decimal number [01,12].
%p Locale's equivalent of either AM or PM.
'''`
==========================================================
print(time.ctime())
print(time.asctime())
t1 = time.time()
t2 = time.localtime(t1)
print(time.ctime(t1))
print(time.asctime(t2))
time.sleep(3)
import datetime
print(datetime.datetime.now())
# 2017-06-26 23:22:25.128901
print(datetime.datetime.now() + datetime.timedelta(+3)) # 当前时间的3天后时间
# 2017-06-29 23:22:25.128901
print(datetime.datetime.now() + datetime.timedelta(-3)) # 当前时间的3天后时间
# 2017-06-23 23:22:25.128901
print(datetime.datetime.now() + datetime.timedelta(hours=3)) # 当前时间的3小时后时间
# 2017-06-27 02:22:25.128901
print(datetime.datetime.now() + datetime.timedelta(hours=-3)) # 当前时间的3小时前时间
# 2017-06-26 20:22:25.128901