There are tons of questions about time and time conversions, and there seems to be no consensus on the βbest way.β
Accordingly: http://lucumr.pocoo.org/2011/7/15/eppur-si-muove/ , pytz is the best way. it shows a timezone conversion like this datetime.datetime.utcnow().replace(tzinfo=pytz.utc) , but it doesn't say how to get a custom timezone ...
This guy https://stackoverflow.com >
Everyone I see using pytz with has their own timezone ( users_timezone = timezone("US/Pacific") ), which I donβt understand, because you canβt know if your viewer is there ...
This guy, https://stackoverflow.com/a/168269/ has a way to automatically detect time zones, but it uses the dateutil library, not pytz, as recommended by both Armin Ronacher and official python docs ( http: //docs.python. org / library / datetime.html # strftime-and-strptime-behavior , just above this anchor in the yellow field)
All I need is the simplest, most reliable future, all daylight saving time / etc, considered as a way to take my stamp datetime.utcnow () ( 2012-08-25 10:59:56.511479 ), convert it to the user's time zone. And show it like this:
Aug 25 - 10:59AM
and if the year is not this year, I would say
Aug 25 '11 - 10:59AM
source share