About Displaying Dates and Times in User's Timezone
To show a datetime
in a user's selected or autodetected timezone, use the following snippet:
{% load tz %}
{% with user_timezone=request.user.timezone|default:"UTC" %}
{{ post.published_from|timezone:user_timezone|date:"j M, Y" }}
{% endwith %}
This assumes that your custom User
model has a timezone
field.
Tips and Tricks Programming Development Django 5.2 Django 4.2 Django 3.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.