Question

Simply put, I've forced my application to use UTC to make it easier on my logic when using different servers in different timezones which all write to the same database. Now, the dilemma seems to be translating these UTC dates into local timezones.

For example, I'm in PST (or PDT, curse you daylight-savings time!), and I'm looking at a value which represents an item's expiration date. Since I'm UTC-7 (I think), and the item expires 48 hours from now, a simple filter of date:"F dS" yields November 10th, rather than November 9th, as expected, as it's currently 6:30PM on November 7th.

Is there a template filter which will convert my date to the current request's timezone or to a given timezone passed as a parameter?

Was it helpful?

Solution

Djnago docs have a how-to on custom template tags, which features a timezone filter.

The same example is in the 1.3 docs too.

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top