How to format dateTime in django template?

Issue

That:

{{ wpis.entry.lastChangeDate|date:"D d M Y" }}

gives me (why?):

2009-07-24 21:45:38.986156 

and i don’t know how to skip fraction part…

In my model i have:

addedDate = models.DateTimeField(default=datetime.now)

Solution

You can use this:

addedDate = datetime.now().replace(microsecond=0)

Answered By – Coc B.

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published