To be brief.
next_contact
is a UTC datetime
When I write in template
{{ event.next_contact }}
I get properly localized date and time But in this place I want output only time so I do:
{{ event.next_contact.time }}
and then I get non localized time
How to fix it??
Use {{ event.next_contact|localtime|date:"H:i" }}
. If you have set USE_TZ=True
you can skip the localtime
filter.
As of Django 1.7 when passed a datetime value with attached timezone information (a time-zone-aware datetime instance) the time
filter will accept the timezone-related format specifiers 'e', 'O' , 'T' and 'Z'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With