On 07/02/10 18:28, Wayne Dyck wrote:

Is there an easy way to format this date_field to my local time zone
i.e. PST? I have also tried using the "date" and "time" filters within
the template itself, however, those are still UTC.

Any pointers would be appreciated.


Well, django-timezones has a template filter that'll show in localtime.
In general, setting django and your database to use UTC internally and using django-timezones to format user-facing time to local time is the sensible way to go.
http://github.com/brosner/django-timezones/

However, in your case, you may still have to write your own (possibly genericized) view, though, if you want to offset the achive view's date argument from its url to be in local time rather than UTC. The ones in question are not particularly complex:

http://code.djangoproject.com/browser/django/trunk/django/views/generic/date_based.py

- basically you'd just have to augment it slightly to transform its
args from your desired timezone to UTC before doing the filter, otherwise you could get some objects from a few stray hours at the "edges" of each month taken relative to local time. Depending on your use case, this may not matter to you though.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to