Hi Guys,
I want to convert a UTC timestamp so I can use it to figure out what
offset a certain user has based on their selected timezone. I'm using
the Python pytz module by the way.
Here is the code so far:
==========
# get users time
timezone = timezone('America/New_York')
# get UTC time
now = datetime.utcnow()
now.strftime()
# begin timezone conversion
utc_dt = datetime(now, tzinfo=utc)
# this is the date and time to print
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
tz = utc_dt.astimezone(timezone)
tz.strftime(fmt)
==========
The problem I am having is converting utc_dt into a format I can use.
I've seen examples that do this:
utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
But the problem is how do I get my now variable into that format?
Cheers,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---