import time
print(time.time()) # 当前时间戳
print(time.altzone) # 与格林威治相差的时间
print(time.asctime()) # Sat Feb 18 15:12:23 2017
print(time.localtime(time.time()-(60*60*24))) # 时间对象,time.localtime().tm_year 返回2017
print(time.gmtime(time.time()+(60*60*24))) # 格林威治utc时间对象
print(time.ctime()) #Sat Feb 18 15:23:02 2017
# print(time.strftime('%Y-%m-%d %H:%M:%S',时间对象如localtime)) # 定义时间格式
# 时间转成时间戳
stuct_time = time.strptime('2017-02-17','%Y-%m-%d') # 时间对象
print(time.mktime(stuct_time))
import datetime
curr_time = datetime.datetime.now()
# 时间戳转成时间
print(datetime.datetime.fromtimestamp(time.time()))
res1 = curr_time + datetime.timedelta(3)
print('res1:',res1)
res2 = curr_time + datetime.timedelta(hours=3)
print('res2:',res2)
res3 = curr_time + datetime.timedelta(minutes=30)
print('res3:',res3)
print(curr_time.replace(year=2011,minute=3,hour=2