On 11/08/2006 11:35 PM, John Machin wrote: > On 11/08/2006 11:10 PM, Simen Haugen wrote: >> Hi. >> >> How can I convert a python datetime to a timestamp? It's easy to convert >> a timestamp to datetime (datetime.datetime.fromtimestamp(), but the >> other way around...?) >> >> -Simen >> > > Is the timetuple() method what you want? > > #>>> import datetime > #>>> n = datetime.datetime.now() > #>>> n > datetime.datetime(2006, 8, 11, 23, 32, 43, 109000) > #>>> n.timetuple() > (2006, 8, 11, 23, 32, 43, 4, 223, -1)
Aaaarrrggghhh no it's not what you want -- looks like you have to do the arithmetic yourself, starting with toordinal() -- http://mail.python.org/mailman/listinfo/python-list