python: bigint 和 time 互转

import time
def bigintToDateTime(d):
return time.localtime(d)

 

def dateTimeToBigint(d=None):
if d==None:
d=time.gmtime()
return int(time.mktime(d))

 

def stringToDateTime(s):
return time.strptime(s, "%Y-%m-%d %H:%M:%S")

 

def dateTimeToSting(d):
if d==None:
d=time.gmtime()
return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(d))



int(time.mktime(postTime.timetuple()))

你可能感兴趣的:(python)