Quantcast
Channel: Have a correct datetime with correct timezone - Stack Overflow
Browsing index pages (4 articles)
↧

Have a correct datetime with correct timezone

I am using feedparser in order to get RSS data.Here is my code :>>> import datetime>>> import time>>> import feedparser>>>...

View Article


Answer by Tuan Anh Hoang-Vu for Have a correct datetime with correct timezone

Try this:>>> import os>>> os.environ['TZ'] = 'Europe/Paris'>>> time.tzset()>>> time.tzname('CET', 'CEST')

View Article


Answer by oxymor0n for Have a correct datetime with correct timezone

feedparser does provide the original datetime string (just remove the _parsed suffix from the attribute name), so if you know the format of the string, you can parse it into a tz-aware datetime object...

View Article

Answer by jfs for Have a correct datetime with correct timezone

feedparser returns time in UTC timezone. It is incorrect to apply time.mktime() to it (unless your local timezone is UTC that it isn't). You should use calendar.timegm() instead:import calendarfrom...

View Article
Browsing index pages (4 articles)


Latest Images