Convert date/time to unix timestamp?

Phillip B Oldham phillip.oldham at gmail.com
Tue Feb 10 04:26:46 EST 2009


Is there a simple way to set a date/time and convert it to a unix
timestamp? After some googling I found the following:

t = datetime.time(7,0,0)
starttime = time.mktime(t.timetuple())+1e-6*t.microsecond

That seems like very long-winded. Is there an easier way? I've read
the docs on the datetime and time modules, but nothing's jumping out
at me.



More information about the Python-list mailing list