This entry was posted on Tuesday, April 24th, 2012 at 12:01 pm and is filed under Tech Stuff. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
There doesn’t seem to be a way to get a Unix timestamp directly from a datetime object in Python, the best workaround example I could find is:
|
1 2 3 4 5 6 7 |
[code] from datetime import datetime import time now = datetime.now() u = str(long(time.mktime(now.timetuple()))) [/code] |
This gets the timestamp as a string, it seems a bit long winded, so if anybody knows a better way please let me know!
