How to display AGE in days [CMS, blog posts]


I’m using the CMS to display dynamic information on my site. I’m wondering if there’s a way to display age?

For example, I’ll have a card and I want the age to be displayed as “1d” which tells the reader this card is 1 day old. I’m currently displaying a shortened calendar date but would much prefer a ‘days old’ approach.

If I could also change elements when a post becomes ‘X Days’ old, that would also be great.

Any advice on this would be appreciated.

There are custom code solutions to this problem. I typically use day.js to handle all the conversion and formatting options when needed. You can do it with vanilla JS but it can quickly become complicated versus a library that addresses all the use cases.