Skip to content
On this page

Masks

Mask Targets

Masks are used to properly format and/or parse dates for VCalendar and VDatePicker.

Property NameTarget AreaDefault Mask
titleCalendar header title"MMMM YYYY"
weekdaysCalendar weekday headers"W"
navMonthsMonth labels in navigation dropdown"MMM"
dayPopoverDate header in day popover when user hovers selected date"WWW, MMM D, YYYY"
dataParses attribute dates, if needed["L", "YYYY-MM-DD", "YYYY/MM/DD"]
modelValueDate picker model value when using v-model.string modifier"iso"
inputDate picker input element text when is-inline === false["L", "YYYY-MM-DD", "YYYY/MM/DD"]

Parsing using multiple masks

Note how an array was used to specify the input mask for VDatePicker. This is because it uses the supplied masks(s) to parse, as well as display, the selected date. The first supplied mask is used to display the date selection, while all masks are used (from first to last) to parse the date string. The first successfully parsed date is used as the selected date. This provides more flexibility for the user when manually typing in dates.

By default, VDatePicker will first try and use the localized long date mask to parse the date, but will also try to parse masks that are globally unambiguous (YYYY-MM-DD and YYYY/MM/DD). Furthermore, because VDatePicker uses its own parsing logic (rather than relying on the browser's inconsistent Date.parse function), it can properly parse ISO-8601 dates to the user's local time zone instead of converting to UTC.

If you plan on targeting browsers from multiple locales, it is probably best to defer to the default mask settings.

Mask Tokens

Use the following tokens to configure your custom masks:

TokenOutput
MonthM1, 2, ..., 12
MM01, 02, ..., 12
MMMJan, Feb, ..., Dec
MMMMJanuary, February, ..., December
Month DayD1, 2, ..., 31
DD01, 02, ..., 31
Do1st, 2nd, ..., 31st
Week Dayd1, 2, ..., 7
d1, 2, ..., 7
dd01, 02, ..., 07
WS, M, ..., S
WWSu, Mo, ..., Sa
WWWSun, Mon, ..., Sat
WWWWSunday, Monday, ..., Saturday
YearYY70, 71, ... 69
YYYY1970, 1971, ..., 2069
Hourh1, 2, ..., 11, 12
hh01, 01, ..., 11, 12
H0, 1, ..., 22, 23
HH00, 01, ..., 22, 23
Minutem1, 2, ..., 59, 60
mm01, 02, ..., 58, 59
Seconds1, 2, ..., 58, 59
ss01, 02, ..., 58, 59
Fractional SecondS0, 1, ..., 8, 9
SS0, 1, ..., 98, 99
SSS0, 1, ..., 998, 999
AM/PMAAM PM
aam pm
TimezoneZZ-11, -10, ..., +10, +11
ZZZ-1100, -1000, ..., +1000, +1100
ZZZZ-11:00, -10:00, ..., +10:00, +11:00
Localized DateL01/21/1983 (en-US), 21/01/1983 (en-GB), ..., 1983/01/21 (civilized)

Released under the MIT License.