import time
localtime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
print localtime #结果是 2015-10-13 15:59:13
#将日期转化成时间戳:
int_localtime=int(time.mktime( time.strptime(localtime, "%Y-%m-%d %H:%M:%S")))
print int_localtime #结果是 1444723153
#将时间戳转化成日期格式
date_localtime=time.strftime("%Y-%m-%d %H:%M", time.localtime(int_localtime))
print date_localtime # 结果是 2015-10-13 15:59:13
时间: 2024-10-26 09:28:02