Skip to content

Syntax ​

Case and extra whitespace are ignored everywhere.

v-model: null

Units ​

Seconds (only with precision="second"), minutes, hours, days and weeks. Months and years are left out because their length varies. m always means minutes.

UnitEnglishGerman
seconds sec secs second secondss sek sekunde sekunden
minutem min mins minute minutesm min minute minuten
hourh hr hrs hour hoursh std stunde stunden
dayd day daysd t tag tage tagen
weekw wk wks week weeksw wo woche wochen

The other built-in locales are accepted when you pass them in the locales prop, e.g. :locales="[fr, en]". Each of them also accepts h, m, min, s, d and w.

UnitSpanish (es)French (fr)Portuguese (pt)
secondseg segs segundo segundossec secs seconde secondesseg segs segundo segundos
minutemins minuto minutosmn mins minute minutesmins minuto minutos
hourhr hrs hora horasheure heureshr hrs hora horas
daydía días dia diasj jour joursdia dias
weeksem semana semanassem semaine semainessem semana semanas
UnitHindi (hi)Arabic (ar)Chinese (zh)
secondसे सेकंड सेकेंड सेकण्डث ثانية ثانيتان ثوان ثواني秒 秒钟
minuteमि मिनट मिनिटد دقيقة دقيقتان دقائق分 分钟 分鐘
hourघं घंटा घंटे घण्टा घण्टेس ساعة ساعتان ساعات时 小时 个小时 钟头 小時 個小時 鐘頭
dayदि दिनي يوم يومان أيام يومًا天 日
weekसप्ताह हफ़्ता हफ़्तेأ أسبوع أسبوعان أسابيع أسبوعًا周 星期 个星期 礼拜 週 禮拜

Arabic also accepts the forms after ين (ساعتين), and spellings without hamza or with ه for ة (اسبوع, ساعه).

Which names are accepted depends on the locales prop (English and German by default). To add a language or more names, see Locales.

With the default minute precision, seconds are not a unit, so 30s is an unknown_unit error.

Compound values ​

1d 2h 30min, 2d4h, 1 hour, 30 minutes. Parts can be separated by spaces, ,, + or &, and by the separator words of the active locales (and, und, y, et, e, और, و, 和). Unit names may end with a period, as in 2 Std. 30 Min.

Chinese is written without spaces, so its separators (和, 又, 零) may be attached to the unit before them: 1小时零5分钟. Chinese and Japanese separators in custom locales work the same way.

Implicit units ​

A single trailing number takes the next smaller unit: 1h30 is 1h 30min and 1d 4 is 1d 4h.

  • Only one trailing number is allowed: 1h 30 15 is a missing_unit error.
  • The "next smaller unit" depends on the precision. 1m 30 is 1m 30s with precision="second", and a missing_unit error otherwise.
  • Custom units never take the trailing number: it goes to the next smaller built-in unit.
  • Turn it off with :implicit-units="false".

Decimals ​

1.5h or 1,5h. Results are rounded to whole minutes, or to whole seconds with precision="second".

Digits ​

Besides 0–9, Arabic-Indic (٣٠), Persian (۳۰), Devanagari (३०) and full-width digits (30) are accepted, in every locale. So are the Arabic decimal separator ٫, the commas ، 、 ,, and the full-width : and +: ١٫٥ ساعة, 1小时,30分钟, 1:30. Error tokens show the input as typed.

Clock format ​

h:mm, e.g. 1:30 or 26:05. With precision="second", h:mm:ss works too. Minutes and seconds need two digits between 00 and 59, so 1:5 is invalid.

ISO 8601 ​

PT1H30M, P1DT2H or P2W, e.g. pasted from an API. Lowercase, decimals (PT1,5H) and weeks together with days (P1W2D) are accepted. Years and months (P1Y, P1M) are not.

Seconds are accepted in ISO input even at minute precision, and they get rounded: PT30S becomes 1 minute.

Bare numbers ​

A number without a unit (45) is rejected with missing_unit, because it's ambiguous. Set default-unit="minute" to accept it:

v-model: null

Typos ​

Unknown units get a suggestion from the unit names of the active locales and precision: 2 huors gives Unknown unit "huors". Did you mean "hours"? Words shorter than 5 characters may be one edit away from a unit name, longer ones two. Names shorter than 3 characters (h, d, ...) are never suggested.

Errors ​

CodeWhen
emptyNothing entered, with required
invalid_formatNot a duration at all (hello, 1:5, P1Y), a stray word (2h foo), or longer than 256 characters
unknown_unitA number followed by an unknown word (5 parsecs)
missing_unitA number without a unit (45, 1h 30 15)
out_of_rangeBelow min or above max

Released under the MIT License.