Check out the source of Brian Rosner's project here:
http://code.google.com/p/django-timezones/

-Rob

On Jun 13, 1:07 am, Darthmahon <[EMAIL PROTECTED]> wrote:
> Hi Guys,
>
> I want to convert a datetime field for an entry in my database to a
> specified timezone. Here is the code I have so far:
>
> from dateutil.parser import *
> from dateutil.tz import *
> from datetime import *
>
> event = get_object_or_404(Event, id__exact=eventid)
> edate = event.date
> tz = gettz('America/New_York')
> edatetz = edate.astimezone(tz)
>
> Now, when I do this, I get something along the lines of "naive
> datetime" for the edate variable. However, if I change the edate
> variable to the following line of code, it works:
>
> edate = datetime.now(tz=gettz('UTC'))
>
> Any ideas why this is happening? Is it the way I am storing the
> datetime in my MySQL database? I'm using a standard datetime field -
> is it missing something?
>
> 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 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