It turns out its my stupid host that's not handling the dates
properly.  I wrote a Python script and tested:

#! /usr/bin/env python

import os
import datetime

def do_test(tz):
   if tz != '':
      os.environ['TZ'] = tz
   print '%20s:  %s' % (tz, datetime.datetime.today())

[do_test(tz) for tz in ('', 'America/New_York', 'America/Denver')]

This outputs:

                            :  2008-09-03 17:28:43.784919
America/New_York:  2008-09-03 23:28:43.784996
    America/Denver:  2008-09-03 23:28:43.785047

As you can see, it don't workee.  I then discovered the timezone "EST
+05EDT,M4.1.0,M10.5.0", here: http://docs.python.org/lib/module-time.html
and gave that a try.  Here's the output now correctly showing 2 hours
difference:

                            :  2008-09-03 17:32:54.726285
America/New_York:  2008-09-03 23:32:54.726363
    America/Denver:  2008-09-03 23:32:54.726409
EST+05EDT,M4.1.0,M10.5.0:  2008-09-03 19:32:54.726451

So if there's any Westhosters out there, you'll benefit from this.


On Aug 25, 11:30 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Here's more info:
>
> $ ./manage.py shell
> Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)>>> from datetime import datetime
> >>> datetime.today()
>
> datetime.datetime(2008, 8, 26, 3, 25, 47, 588753)
>
> $ python
> Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> from datetime import datetime
> >>> datetime.today()
>
> datetime.datetime(2008, 8, 25, 21, 26, 21, 383524)
>
> Keith
>
> On Aug 25, 11:11 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I'm a little confused about theTIME_ZONEsetting in settings.py.  I
> > originally had it set to 'America/New_York', because that's the time
> > zone where I'm located, but I noticed the times were ~4 hours off when
> > I would save an object that had a DateTimeField(auto_now_add=True)
> > field in the model.  Instead I tried to set theTIME_ZONEvalue to
> > where the web server was, Utah, so I used 'America/Denver'.
>
> > I saved an object while configured for Denver, timestamp was for
> > 2:40am.  I changed the setting back to New_York and saved another
> > object, the the timestamp was for 2:52am.  Local time for me was
> > ~10pm.
>
> > Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> > [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.>>> 
> > import datetime
> > >>> datetime.datetime.today()
>
> > datetime.datetime(2008, 8, 25, 21, 9, 15, 497672)
>
> > $ date
> > Mon Aug 25 21:09:45 MDT 2008
>
> > I would like the times to shown as Eastern Time zone.  What should I
> > set theTIME_ZONEsetting to?
>
> > Keith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to