[Django]-Is there a Django template filter that turns a datetime into "5 hours ago" or "12 days ago"?

18👍

Try the template filter timesince.

Use it like this:

{{ mytemplatevar|timesince }}
👤mpen

4👍

UPDATED:
We can assume that you have a post_date attribute saved in your model capturing the time you save the post. present.time is the current time that is loaded freshly onto the template when one visits the post. This would be the recommended implementation of what you are looking for:

Submitted on {{ present.date|timesince:post_date }} ago.

1👍

Try this snippet. It is not built in django before 1.3

Leave a comment