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
2009-05-10 09:43:02
Thanks, just what I was looking for :)/me should've read the docs better
Yuvi
2009-05-10 09:45:23