Time to now2.10.3+

  1. moment().toNow();
  2. moment().toNow(Boolean);

A common way of displaying time is handled by moment#toNow. This is sometimes called timeago or relative time.

This is similar to moment.fromNow, but givesthe opposite interval: a.fromNow() = - a.toNow().

This is similar to moment.to, but is special-casedfor the current time. Use moment.to, if you want to control the two endpoints of the interval.

  1. moment([2007, 0, 29]).toNow(); // in 4 years

If you pass true, you can get the value without the prefix.

  1. moment([2007, 0, 29]).toNow(); // in 4 years
  2. moment([2007, 0, 29]).toNow(true); // 4 years

The base strings are customized by the current locale.

The breakdown of which string is displayed for each length of time is outlined in the table below.

RangeKeySample Output
0 to 44 secondssin seconds
45 to 89 secondsmin a minute
90 seconds to 44 minutesmmin 2 minutes … in 44 minutes
45 to 89 minuteshin an hour
90 minutes to 21 hours hhin 2 hours … in 21 hours
22 to 35 hoursdin a day
36 hours to 25 daysddin 2 days … in 25 days
26 to 45 daysMin a month
45 to 319 daysMMin 2 months … in 10 months
320 to 547 days (1.5 years)yin a year
548 days+yyin 2 years … in 20 years

From version 2.10.3, if the target moment object is invalid the result isthe localized Invalid date string.