user9931820
user9931820

Reputation:

How to render human-readable dates in Django?

I am building a Django app where I need to render publication dates.

As of now, dates rendered on my templates look something like this:

published on February 10, 2020

Can I leverage Django's templating engine to make them more human-readable, like the following for example?

published an hour ago

Upvotes: 0

Views: 355

Answers (1)

Arjun Shahi
Arjun Shahi

Reputation: 7330

You can use timesince like this in your template

Published {{your_date_time_field|timesince}} ago

See the docs for more info

Upvotes: 1

Related Questions