You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With or without spaces: '1h30m', '1h 30m', '1hour', '1 hour'
Case insensitive: '1H', '30M', '1 HOUR'
Negative values: '-1h', '-30m'
Supported units:
Unit
Short
Shorter
Long (singular)
Long (plural)
Nanoseconds
ns
nsec, nsecs
nanosecond
nanoseconds
Milliseconds
ms
msec, msecs
millisecond
milliseconds
Seconds
s
sec, secs
second
seconds
Minutes
m
min, mins
minute
minutes
Hours
h
hr, hrs
hour
hours
Days
d
-
day
days
Weeks
w
-
week
weeks
FAQ
Why no months/years?
Months and years aren't fixed durations. They vary (28-31 days for months, 365-366 for years). Any approximation would be silently wrong in many cases. Be explicit instead: use '30d' for ~1 month or '365d' for ~1 year.
What's the difference from ms?
This package parses combined units like '1h 30m' and '2 days 5 hours'. The ms package does bidirectional conversion but doesn't support combined units.
Localization support?
No. This keeps the package simple and small.
Dates, timestamps, or time zones?
No. This only parses relative durations (lengths of time), not absolute times.
Related
pretty-ms - Convert milliseconds to a human readable string
to-milliseconds - Convert an object of time properties to milliseconds