bwbrowning bwbrowning - 1 year ago 97
Python Question

Django datetimefield time in template

I have a

in one of my models

If I display
{{ model.datetime }}
in the template, I see:

Aug. 13, 2013, 7:57 p.m.

If I display
{{ model.datetime.time }}
in the template , I see:

2:57 am

I want it to just display
7:57 p.m.
How can I get it to use the correct timezone. I have tried with
as well but with the same result.

Answer Source


{{ model.datetime|date:"g:i a" }}

If you want a different format, refer to the documentation here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download