I am storing all my times in UTC and my system is set to UTC (though I am in EST).
I have dates stored as:
Wed, 20 Feb 2013 03:51:39 +0000
However, I would like to select information based off today for EST, so I am attempting to:
Get current time as UTC and change to EST
datetime.utcnow().replace(tzinfo=tz.tzutc()).astimezone(tz.gettz('America/New_York')) 2013-02-19 23:17:20.560898-05:00
Next I want to get the start time for the EST day (2013-02-19 00:00:00.000000-05:00) and the end time (2013-02-19 23:59:59.99999-05:00)
Once I have those values, I'd like to convert back to UTC, so I have a high and low value I can clamp by that's correct my EST (my timezone).
If this isn't the best way to do this, or I'm missing something (does seem overly complicated to me) please help me see the light!
TIA
Update per answer:
d1 = datetime.utcnow().replace(tzinfo=tz.tzutc()).astimezone(tz.gettz('America/New_York'))
print d1.strftime("%m %d %Y") ; d2 = d1.replace(day=d1.day + 1) ; print d2.strftime("%m %d %Y")
That will give me
02 20 2013
02 21 2013
Which is correct. I now need to generate the full EST time from that and then convert to UTC. This I cannot figure out. Actually, I probably want to convert to UTC epoch timestamp when complete because that will make my database operations pretty easy (<, >, ==, etc).