Reputation: 6530
I have a DateTimeField
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 model.datetime.timetz
as well but with the same result.
Upvotes: 8
Views: 29363
Reputation: 2536
If you are happy with the default format for your local time, replacing the call to the time()
method with the time
filter will do the job:
{{ model.datetime|time }}
Hth, dtk
Upvotes: 1
Reputation: 99670
Try
{{ model.datetime|date:"g:i a" }}
If you want a different format, refer to the documentation here
Upvotes: 23