Display Date As Time Passed / Time Ago (e.g. 5 mins ago)

Thank you very much for your sharing!!

1 Like

yes, it worked! thanks

Firstly, it did not. But then I realized that my date format was set to eg. Feb 22 and it was counting something like 22 years ago (similar to what juragan had above). Then I changed to 2/22/2022 and it works perfectly.

I only noticed that when the published date is today, it counts the hours from midnight. For example, I just posted an entry (it’s 20:50 now, or 8:50 pm) and it shows “posted 21h ago”. It’s not that big of an issue though. Should be fine for my MVP now.

Maybe I’ll look into having for the entries that were posted today display “today” or “new” and for yesterday’s posts “yesterday” soon (and the rest as it is now). Suggestions welcome :slight_smile:

I changed the format in my collection settings and included hours now too. Then I changed the format of displaying on the site to show that change, and now the code counts the hours accurately (not from midnight as stated above).