Skip to content Skip to sidebar Skip to footer

Pytz Timezone Tags To Adjust Date Printed In Templates

Inside my app I use normal datetime objects. In my template: {% load tz %} {{datetimeobject|timezone:'Europe/Paris'}} {% timezone 'Europe/Paris' %} {{datetimeobject}} {% endtimez

Solution 1:

You say you use "normal datetime objects", but apparently they are timezone naive instead of timezone aware.

The timezone filter "forces conversion of a single value to an arbitrary timezone" while the timezone tag just sets the current timezone until the endtimezone tag.

Your datetimeobject is timezone naive and the timezone filter will convert it to a timezone aware datetime with the default timezone and then represent it in the timezone given to the filter.

Post a Comment for "Pytz Timezone Tags To Adjust Date Printed In Templates"