Relative Time Thresholds2.7.0+

  1. moment.relativeTimeThreshold(unit); // getter
  2. moment.relativeTimeThreshold(unit, limit); // setter

duration.humanize has thresholds which define when a unit is considered a minute, an hour and so on. For example, by default more than 45 seconds is considered a minute, more than 22 hours is considered a day and so on. To change those cutoffs use moment.relativeTimeThreshold(unit, limit) where unit is one of ss, s, m, h, d, M.

unitmeaningusage
ssa few secondsleast number of seconds to be considered seconds. Must be set after setting the s unit or without setting the s unit.
ssecondsleast number of seconds to be considered a minute.
mminutesleast number of minutes to be considered an hour.
hhoursleast number of hours to be considered a day.
ddaysleast number of days to be considered a month.
Mmonthsleast number of months to be considered a year.
  1. // Retrieve existing thresholds
  2. moment.relativeTimeThreshold('ss'); // 44
  3. moment.relativeTimeThreshold('s'); // 45
  4. moment.relativeTimeThreshold('m'); // 45
  5. moment.relativeTimeThreshold('h'); // 22
  6. moment.relativeTimeThreshold('d'); // 26
  7. moment.relativeTimeThreshold('M'); // 11
  8. // Set new thresholds
  9. moment.relativeTimeThreshold('ss', 3);
  10. moment.relativeTimeThreshold('s', 40);
  11. moment.relativeTimeThreshold('m', 40);
  12. moment.relativeTimeThreshold('h', 20);
  13. moment.relativeTimeThreshold('d', 25);
  14. moment.relativeTimeThreshold('M', 10);

Note: Retrieving thresholds was added in 2.8.1.

Note: Retrieving and setting ss threshold was added in 2.18.0.