tags:

views:

165

answers:

1

I'm looking for a filter that turns a datetime instance into 'x Days' or 'x years y months' format (as on SO). Suggestions? Am I overlooking something very obvious?

+7  A: 

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 }}
Ayman Hourieh
Thanks, just what I was looking for :)/me should've read the docs better
Yuvi