Date formatting with moment().fromNow() option


I’d like to display recent posts with date formatted as “3 days ago”. I understand that moments.js supports that, but how can I do that?

Here is the code for the part where the date is displayed in sidebar widget:

`<time class='c-teaser__date' datetime='{{ date format='YYYY-MM-DD' }}' title='{{ date format='DD MMMM YYYY' }}'>{{ date format='DD.MM.YYYY.' }}</time>`



The date helper supports the timeago option :slight_smile:


Or you may try this method called fromNow() -
I am using it like this - const theDateIwant = moment(myDate).fromNow();

closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.