I'd like to reopen this question:

The answer was a plugin called Nice Time

But This plugin is depricated and the creator stats that this functionality is acheivable via the date_modify filter.

Yes okay, but how?

I have a event archive where I want to show "This event happend xy days ago".

There is a time_diff filter in twig. But it seems as if this is not activated in craft.


You could use the diff method to get the number of days between two dates. So for example:

{{ date(entry.dateCreated|date('c')).diff(now).days }} days ago

In my example between today (using now) and the entry.dateCreated.

There is a explanation as to why you need to wrap the first date in the date filter here, which is where I got the answer from!

  • How would I print seconds or hours? .seconds does nothing?
    – KSPR
    Mar 14 '16 at 14:07
  • Instead of .days, use .format, and then use one of the format chars listed here. So for example to get months use .format('%m'). Mar 14 '16 at 14:18

I have a plugin that adds the time_diff Twig filter to Craft:


There is one possible issue (in either PHP or Craft) around DST, and I will add that to the README.

  • Unfortunately that ads a suffix "days ago" which is bad for a german Site :)
    – KSPR
    Mar 14 '16 at 14:08
  • Hi @KSPR - just added a new version that includes an array option with translated strings where possible, and you could then use the raw output to format the diff however you'd like. :) Mar 14 '16 at 15:10
  • Nice :) I'll check it out.
    – KSPR
    Mar 15 '16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.