views:

1559

answers:

2

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.

+1  A: 

A Maybe?

Code I found via Google

websch01ar
If I was working boost that might be helpful. :-)
Jason Baker
No problem mate...I was just trying to be helpful
websch01ar
+9  A: 
import time, datetime

d = datetime.datetime.now()
print time.mktime(d.timetuple())
kender
Thank you. I knew it had to be something stupidly simple, but I couldn't figure it out.
Jason Baker
It seems that depending on the platform, time doesn't have a mktime method
Tirno