[Tutor] question about datetime object
Kent Johnson
kent37 at tds.net
Fri Jul 20 18:00:58 CEST 2007
shawn bright wrote:
> Hello there,
>
> if i have a python datetime object, what is the easiest way to make it
> into epoch seconds ?
impIn [1]: import datetime
In [2]: now = datetime.datetime.now()
In [4]: now.timetuple()
Out[4]: (2007, 7, 20, 11, 56, 58, 4, 201, -1)
In [5]: import calendar
In [6]: calendar.timegm(now.timetuple())
Out[6]: 1184932618
Kent
More information about the Tutor
mailing list