39👍
✅
Have a look at the timesince template filter. It’s builtin.
The following returns a humanized diff between now and comment_date
(e.g. '8 hours'
):
{{ comment_date|timesince }}
The following returns a humanized diff between question_date
and comment_date
:
{{ comment_date|timesince:question_date }}
Source:stackexchange.com