Efficient to show Days / Date Period

Hey Everyone!

I have 1 challenge!

I’m trying to make a notifications’ timer to show how many minutes, hours, days, weeks or months ago a notification has been created.

Here is an example from Facebook:


I thought of creating tests like this, and let each format text as minutes/hours/days and be visible on a condition, like if the number (in minutes is<60) show text a (formatted in minutes)/ If the number is>60 but < 60*24 (minutes in a day) show text b (formatted in hours):


This works but is a bit clumsy. Are you thinking of a more efficient solution?

Moment.js might work :slight_smile:

1 Like

This is amazing! 2 Moment.js displayed blank on me, strangely, but found a third one! feeling happy!