language: Python (python 2.7.3)
date: 497 days 5 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
from datetime import datetime, timedelta
 
def totimestamp(dt, epoch=datetime(1970,1,1)):
    td = dt - epoch
    return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 1e6 # td.total_seconds()
 
now = datetime.utcnow()
print now
print totimestamp(now)