Reputation: 396
I have a createdAt field in my database which stores the current time stamp.And when I render it to my templates it returns in the form of Aug. 24, 2017, 12:58 p.m.
.
What I want it to return in the form of Aug. 24, 2017, 12:58 PM
.That is am/pm should be in caps form.
what I tried in my templates are:-
<td>{{ item.newsId.createdAt|time:"g:iA" }}</td>
and what it returned is only time 10:27AM
.But I want the date also along with this time format.
Upvotes: 1
Views: 642
Reputation: 21
This helps to see the date time in this format: 1 day, 8 hours
suitable to add 1 day, 8 hours ago ;)
<td>{{ item.newsId.createdAt|timesince }}</td>
Upvotes: 0
Reputation: 6865
you can do it like below
<td>{{ item.newsId.createdAt|date:"N j, Y, g:iA" }}</td>
for more configurations visit django builtins date
Upvotes: 2
Reputation: 3483
<td>{{ item.newsId.createdAt|date:"M. d,Y, f A" }}</td>
Hi can you try above one
Upvotes: 0