days since epoch

wittempj@hotmail.com martin.witte at gmail.com
Fri Feb 17 03:52:40 EST 2006


As suggested by Alex the datetime module makes this easy:

py> import datetime
py> epoch = datetime.datetime.utcfromtimestamp(0)
py> print epoch
1970-01-01 00:00:00
py> today = datetime.datetime.today()
py> d = today - epoch
py> print d
13196 days, 9:50:44.266200
py> print d.days # timedelta object
13196




More information about the Python-list mailing list