I'm trying to find the epoch seconds for the most recent midnight in Python.
I found this: What was midnight yesterday as an epoch time?
which has
from datetime import datetime, date, time
midnight = datetime.combine(date.today(), time.min)
'midnight' is now the right time...but how do I get it into epoch seconds? i.e., something like 1393997154 (or 1393997154.09)
Not saying the above the best approach. In perl, I would
my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
$year += 1900;
return timelocal(0,0,0,$mday,$mon,$year);
...in other words, get the struct, change hour/min/sec, then convert it.