df-date-time Component
df-date-time selects a date, a time or both, with Vuetify's date and time pickers.
Basic Usage
df-date-time bound to a vue-forms field:
null
2026-03-15
09:30:00
2026-03-15T09:30:00
Features
- Date only, time only, or both
- Display formats as date-fns patterns
- Date and time pickers in a menu
- Typed dates and times, with short forms such as
1206for 12 June and1843for 18:43 - Clearing the value
Picking a value
A click into the date or the time opens its picker. A choice in a picker is written to the field when it is confirmed: with OK, with Enter, or with a double-click on a day or on the clock. Cancel, Escape and closing the menu leave the field as it was. For 600 ms after the picker changes its view - a chosen hour switches the clock to the minutes, a chosen month or year switches to the days, a day of an adjacent month switches the calendar to that month - a double-click does not confirm. A confirmed choice and a clear mark the field touched.
A click in the picker leaves the focus in the text field. The picker closes when text is typed into the field and when the field loses focus.
Keyboard
| Key | Picker closed | Picker open |
|---|---|---|
<space> | opens the picker while the text shows the value; types a space into edited text | |
← / → | moves the caret | date: one day back / forward; time: one hour back / forward |
↑ / ↓ | opens the picker | date: one week back / forward; time: one minute forward / back |
<enter> | reads the typed text | writes the choice in the picker and closes it |
<esc> | closes the picker and leaves the value | |
<tab> | moves to the next field | closes the picker and moves to the next field |
Focusing the date or the time selects its text, so typing replaces it. Right on the last column of the calendar goes to the first column of the same row of the next month, left on the first column to the last column of the same row of the previous month; where that row holds no day of the month, the step goes to the month's nearest day. Up and down step across months and years, the time steps across midnight. A step on an empty value starts from the current date or time. Left and right show the hours on the clock, up and down the minutes.
Typing a value
The date and the time are each typed into their own text field. The field holds the text as typed and reads it when it loses focus or on Enter; once read, the field shows the value in its display format. Leading and trailing spaces are ignored. A field emptied of its text clears the whole value: in datetime mode, emptying the date or the time clears both.
Each text is read in two steps:
- Text in the display format (
displayFormatDate,displayFormatTime) is read with date-fnsparse()against the component's locale. A date read this way with a year below 1000, such as8/12/27againstMM/dd/yyyy, goes to step 2. - Any other text is read by the rules below.
Time
A time is read in the 24-hour clock. It may end in a or p, written as am, pm, a.m. or p.m. in either case; the hour is then 1–12, 12 am is midnight and 12 pm noon.
| Typed | Read as | Example |
|---|---|---|
| 1 digit | whole hours | 9 = 9:00 |
2 digits up to 23 (up to 12 with am/pm) | whole hours | 18 = 18:00, 12a = 0:00 |
| 2 digits above that | H:0M | 65 = 6:05, 24 = 2:04 |
| 3 digits | H:MM | 130 = 1:30, 930 = 9:30, 130pm = 13:30 |
| 4 digits | HH:MM | 1843 = 18:43, 0005 = 0:05 |
2 or 3 parts of 1–2 digits, separated by spaces, :, ., , or - | hours, minutes and seconds; the seconds are dropped | 18.43, 9 30, 18:43:20 = 18:43 |
An hour above 23 or a minute above 59 is not read.
Date
A date is read in the order of day, month and year of the display format in the component's locale. A display format without a numeric day, month and year, such as PPP, gives the order of the locale's short date format P. Text without a year keeps the order of the day and the month, and takes the current year.
| Typed | Read as | sl (day, month, year) | ja (year, month, day) |
|---|---|---|---|
| 1–2 digits | a day of the current month | 12 = 12th | 12 = 12th |
| 3 digits | first part 1 digit, second part 2 digits | 812 = 8 Dec | 812 = 12 Aug |
| 4 digits | two parts of 2 digits | 1206 = 12 Jun | 0812 = 12 Aug |
| 6 digits | three parts of 2 digits | 120627 = 12 Jun 2027 | 270812 = 12 Aug 2027 |
| 8 digits | a full date with a 4-digit year | 12062027 | 20270812 |
2 parts separated by spaces, ., /, , or - | a day and a month of 1–2 digits each | 12.6 | 8/12 |
| 3 parts separated the same way | a full date; the year has 2 or 4 digits | 12. 6. 27 | 2027/8/12 |
Trailing separators are ignored (12.6.). A two-digit year is the year ending in those digits from 50 years before to 49 years after the current one, the year date-fns parse() reads for yy. A date that does not exist, such as 31 February or sl 131 (1st of month 31), is not read; 5 or 7 digits, or more than 8, are not read either.
Text that is not read
Text that is not read stays in the field and the value is left as it is. The field holds an error of code vuetify-inputs.invalid_date or vuetify-inputs.invalid_time with origin 'application' until its text is read, the text shown for the value is typed again, or the value changes: a bound control holds the error in its errors and is invalid, and a field without a control shows it.
Props
In addition to common props from InputBase, this component supports:
| Prop | Type | Default | Description |
|---|---|---|---|
| inputType | 'datetime' | 'date' | 'time' | 'datetime' | Input type - date and time, date only, or time only |
| displayFormatDate | string | 'P' | Date display format (date-fns format) |
| displayFormatTime | string | 'p' | Time display format (date-fns format) |
| locale | Locale | undefined | date-fns locale object for formatting and parsing. Without it, the dateTimeLocale setting applies, and without that DateTimeLocaleConfig |
| timeZone | string | undefined | The time zone of the value in datetime mode: an IANA name or 'wall'; see Time zone. Without it, the timeZone setting applies, and without that the browser's zone |
Value Format
The component accepts and outputs values in the following formats:
- datetime mode: ISO 8601 format (
YYYY-MM-DDTHH:mm:ssXXX); withtimeZone: 'wall', without the offset (YYYY-MM-DDTHH:mm:ss). The value written carries the offset of the user's local time zone, or of the zonetimeZonenames, in force on that date and time; in a zone with daylight saving time a January value carries the winter offset regardless of the date of editing. A zero offset is written asZ. - date mode: ISO 8601 date format (
YYYY-MM-DD). A bound value is read by its date part as written, in every browser zone and with anytimeZone:2026-07-15T23:30:00+02:00shows 15 July also inAsia/Tokyo, where that instant falls on 16 July. A bound value whose date is notYYYY-MM-DDor names a day that does not exist (2026-02-30) is not read. To show an instant as its date in a zone, convert it withdateInZoneand bind the result. - time mode: 24-hour time format (
HH:mm:ss). The time is read and written as given, also on a day the browser's zone changes its offset.
The component writes a value only when the user edits the date or the time. A datetime-mode value is shown in the user's local time, in the zone timeZone names, or, with 'wall', by its date and time as written. A bound value is kept in the field as given, with its own offset (Z included), so displaying a record neither changes the field nor marks it as changed.
A bound value that is not read
A bound value is read where its date is YYYY-MM-DD and names a day that exists, and its time, where it has one, is HH:mm, HH:mm:ss or HH:mm:ss.sss, optionally followed by an offset from -23:59 to +23:59 (Z, +02:00), and names a time that exists. The date and the time are separated by T or a space. In time mode the value is such a time. An empty string is an empty value; a value that is not a string, such as a Date, is not a date.
Any other value, such as 'not a date', '20260715', '2026-07-15Tfoo', '2026-02-30', '2026-13-01' or '2026-07-15T25:00:00+02:00', is not read, in every mode and with any timeZone:
- it is reported with
console.erroronce per bound value, naming the field by its label, or by the control's field name where it has no label, the value and the reason: it is not a date (in time mode, not a time), the day does not exist, or the time does not exist; - the field holds the error
vuetify-inputs.invalid_date, orvuetify-inputs.invalid_timewhere the time is not read, with origin'application', as for text that is not read: a boundcontrolholds it in itserrorsand is invalid at once. The error is shown by the usual rules, once the field is touched. Date mode reportsinvalid_dateand time modeinvalid_time. A control that replaces the bound one takes the error over; - the field shows the value as written: in datetime mode the date part and the time part each in its own field, or the whole value in the date field where its date is not
YYYY-MM-DD; in date and time modes the whole value.
The value stays as it is until the user edits the date or the time. An edit that is read writes a value and removes the error; in datetime mode the part not edited keeps its date or time where that can be read, and takes the current date or time where it cannot. Binding a value that can be read removes the error; a value that cannot be read bound after it is reported again.
Time zone
timeZone sets the time zone of a datetime-mode value, for an app that places dates and times in a zone of its own, such as the zone of a public-transport stop. Date and time modes ignore it: a date is a calendar date and a time a wall-clock time, both read and written as given. The date picker and the time picker show the day and the time in that zone, whatever the browser's zone.
- Not set: the browser's zone.
- An IANA name (
'Europe/Ljubljana','America/New_York','UTC'): the field shows and edits the value's wall-clock date and time in that zone. A bound value with an offset (Zincluded) is converted to that zone:2026-07-15T16:00:00+02:00shows 10:00 on 15 July inAmerica/New_York. A bound value without an offset is read as wall-clock time in that zone. The value written carries the zone's offset in force at that date and time:- a time the zone skips at a daylight saving time change moves forward by the gap: in
Europe/Ljubljana, 2026-03-29 02:30 is written as2026-03-29T03:30:00+02:00; - a time the zone repeats takes its first occurrence: in
Europe/Ljubljana, 2026-10-25 02:30 is written as2026-10-25T02:30:00+02:00.
- a time the zone skips at a daylight saving time change moves forward by the gap: in
'wall': the value is wall-clock time without an offset, read and written without conversion:- a value is shown as written in any browser zone, also a time that zone skips or repeats at a daylight saving time change:
2026-03-08T02:30:00shows 02:30 inAmerica/New_York, where that night goes from 2:00 to 3:00; - the value written is
YYYY-MM-DDTHH:mm:ss; a bound value may omit the seconds (YYYY-MM-DDTHH:mm) and may be separated by a space in place ofT; - a bound value with an offset (
Zincluded) or fractional seconds is shown by its date and time as written, without them:2026-07-15T10:00:00+02:00shows 10:00 in every zone; the value written once the user edits the date or the time has no offset; - a bound value whose date is not
YYYY-MM-DD, whose time is notHH:mm, or that names a day or a time that does not exist (2026-02-30,25:00) is not read.
- a value is shown as written in any browser zone, also a time that zone skips or repeats at a daylight saving time change:
- An unknown name is reported with
console.warn, once per name, and the browser's zone is used.
<df-date-time v-model="departure" time-zone="Europe/Ljubljana" label="Departure" />
<df-date-time v-model="arrival" time-zone="wall" label="Arrival" />An app whose date-time fields all use one zone sets the timeZone setting instead.
2026-07-15T23:30:00+02:00
Editing the date or the time rewrites the bound value in the selected zone's form; with 'wall', without an offset.
Browser zone:
dateInZone
dateInZone(value: string, timeZone?: string): string | null returns the date (YYYY-MM-DD) of an ISO 8601 value in a time zone. An app that shows an instant as a date in date mode converts it with dateInZone and binds the result.
- A value with a time and an offset (
Zincluded) is an instant; the result is its date intimeZone, an IANA name, with the offset in force at that instant, or in the browser's zone whentimeZoneis not given:dateInZone('2026-07-15T23:30:00+02:00', 'Asia/Tokyo')is'2026-07-16', with'America/New_York'it is'2026-07-15'. - With
'wall', and for a value without an offset (2026-07-15,2026-07-15T23:30:00), the result is the value's date part as written. - A value that is not ISO 8601, or names a day or a time that does not exist (
2026-02-30,25:00), givesnull. - An unknown zone name is reported with
console.warn, once per name, and the browser's zone is used.
import { Field } from '@dynamicforms/vue-forms';
import { dateInZone } from '@dynamicforms/vuetify-inputs';
const departure = '2026-07-15T23:30:00+02:00';
const departureDay = new Field({ value: dateInZone(departure, 'Asia/Tokyo') }); // '2026-07-16' Instant: 2026-07-15T23:30:00+02:00
2026-07-15T23:30:00+02:00
2026-07-16
Display Format
Dates and times are displayed with date-fns format patterns:
- Default date format:
'P'(locale-specific date representation) - Default time format:
'p'(locale-specific time representation)
Common format strings:
'yyyy-MM-dd'- 2023-04-17'dd.MM.yyyy'- 17.04.2023'HH:mm'- 14:30'HH:mm:ss'- 14:30:45
Locale
The date-fns locale sets the display format, the parsing of typed text and the first day of the week; the locale prop overrides the global one for one component. See Localisation: Dates and times.
Events
This component emits the common events of InputBase.
Examples
Date Only Picker
<template>
<df-date-time
v-model="selectedDate"
input-type="date"
display-format-date="dd.MM.yyyy"
label="Select Date"
hint="Format: DD.MM.YYYY"
/>
</template>
<script setup>
import { ref } from 'vue';
import { DfDateTime } from '@dynamicforms/vuetify-inputs';
const selectedDate = ref('2023-04-17');
</script>Date and Time Picker with DynamicForms
<template>
<df-date-time
:control="form.fields.meetingTime"
label="Meeting Time"
hint="Select the date and time for your meeting"
/>
</template>
<script setup>
import { Group, Field } from '@dynamicforms/vue-forms';
import { DfDateTime } from '@dynamicforms/vuetify-inputs';
const form = new Group({
meetingTime: new Field({
value: '2026-03-15T09:30:00'
})
});
</script>