datetime issue

Chris Rebert clp2 at rebertia.com
Sat Sep 15 15:05:23 EDT 2012


On Sat, Sep 15, 2012 at 10:33 AM, Νικόλαος Κούρας <nikos.gr33k at gmail.com> wrote:
> Hello again,
>
> one small matter too.
>
> # get some enviromental values
> locale.setlocale(locale.LC_ALL, 'el_GR')
<snip>
> date = datetime.datetime.now().strftime( '%y-%m-%d %H:%M:%S' )
>
> although iam setting greek as locale

Locales don't affect timezones. Otherwise, how would expatriate
communities, or countries wide enough to span several timezones,
properly configure their software?

> the time is 8 hours before, like in texas, us

Which is where HostGator operates out of.

> How can i change this to save the correct Greek time in variable $date ?

Use the `pytz` package that Jason pointed out.

Cheers,
Chris



More information about the Python-list mailing list