How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way.
If I was working boost that might be helpful. :-)
Jason Baker
2008-10-31 21:53:48
No problem mate...I was just trying to be helpful
websch01ar
2008-10-31 21:58:26
+9
A:
import time, datetime
d = datetime.datetime.now()
print time.mktime(d.timetuple())
kender
2008-10-31 21:44:35
Thank you. I knew it had to be something stupidly simple, but I couldn't figure it out.
Jason Baker
2008-10-31 21:53:12
It seems that depending on the platform, time doesn't have a mktime method
Tirno
2009-03-19 22:05:51