Getting 'top of the day' epoch in Python
Python's time, date and datetime modules are powerful, but I find I nearly always have to go to the docs to do even basic tasks.
I needed to get the epoch time for Midnight of a day. It took me way to long to figure how to do this, so I'm stowing this away here for next time.
1 2 3
import calendar import datetime calendar.timegm(datetime.date(2012,9,1).timetuple())