Skip to content

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:

DateTime Example
DateTime
Field value:
null
Date Only Example
Date
Field value:
2026-03-15
Time Only Example
Time
Field value:
09:30:00
Multilingual Date Picker
DateTime
Vrednost polja:
2026-03-15T09:30:00
Slovenska lokala: teden se začne v ponedeljek, format dd. mm. llll

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 1206 for 12 June and 1843 for 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 ​

KeyPicker closedPicker open
<space>opens the picker while the text shows the value; types a space into edited text
← / →moves the caretdate: one day back / forward; time: one hour back / forward
↑ / ↓opens the pickerdate: one week back / forward; time: one minute forward / back
<enter>reads the typed textwrites the choice in the picker and closes it
<esc>closes the picker and leaves the value
<tab>moves to the next fieldcloses 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:

  1. Text in the display format (displayFormatDate, displayFormatTime) is read with date-fns parse() against the component's locale. A date read this way with a year below 1000, such as 8/12/27 against MM/dd/yyyy, goes to step 2.
  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.

TypedRead asExample
1 digitwhole hours9 = 9:00
2 digits up to 23 (up to 12 with am/pm)whole hours18 = 18:00, 12a = 0:00
2 digits above thatH:0M65 = 6:05, 24 = 2:04
3 digitsH:MM130 = 1:30, 930 = 9:30, 130pm = 13:30
4 digitsHH:MM1843 = 18:43, 0005 = 0:05
2 or 3 parts of 1–2 digits, separated by spaces, :, ., , or -hours, minutes and seconds; the seconds are dropped18.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.

TypedRead assl (day, month, year)ja (year, month, day)
1–2 digitsa day of the current month12 = 12th12 = 12th
3 digitsfirst part 1 digit, second part 2 digits812 = 8 Dec812 = 12 Aug
4 digitstwo parts of 2 digits1206 = 12 Jun0812 = 12 Aug
6 digitsthree parts of 2 digits120627 = 12 Jun 2027270812 = 12 Aug 2027
8 digitsa full date with a 4-digit year1206202720270812
2 parts separated by spaces, ., /, , or -a day and a month of 1–2 digits each12.68/12
3 parts separated the same waya full date; the year has 2 or 4 digits12. 6. 272027/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:

PropTypeDefaultDescription
inputType'datetime' | 'date' | 'time''datetime'Input type - date and time, date only, or time only
displayFormatDatestring'P'Date display format (date-fns format)
displayFormatTimestring'p'Time display format (date-fns format)
localeLocaleundefineddate-fns locale object for formatting and parsing. Without it, the dateTimeLocale setting applies, and without that DateTimeLocaleConfig
timeZonestringundefinedThe 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); with timeZone: '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 zone timeZone names, 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 as Z.
  • 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 any timeZone: 2026-07-15T23:30:00+02:00 shows 15 July also in Asia/Tokyo, where that instant falls on 16 July. A bound value whose date is not YYYY-MM-DD or 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 with dateInZone and 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.error once 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, or vuetify-inputs.invalid_time where the time is not read, with origin 'application', as for text that is not read: a bound control holds it in its errors and is invalid at once. The error is shown by the usual rules, once the field is touched. Date mode reports invalid_date and time mode invalid_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 (Z included) is converted to that zone: 2026-07-15T16:00:00+02:00 shows 10:00 on 15 July in America/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 as 2026-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 as 2026-10-25T02:30:00+02:00.
  • '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:00 shows 02:30 in America/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 of T;
    • a bound value with an offset (Z included) or fractional seconds is shown by its date and time as written, without them: 2026-07-15T10:00:00+02:00 shows 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 not HH:mm, or that names a day or a time that does not exist (2026-02-30, 25:00) is not read.
  • An unknown name is reported with console.warn, once per name, and the browser's zone is used.
vue
<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.

Time zone
DateTime
Bound value:
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 (Z included) is an instant; the result is its date in timeZone, an IANA name, with the offset in force at that instant, or in the browser's zone when timeZone is 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), gives null.
  • An unknown zone name is reported with console.warn, once per name, and the browser's zone is used.
ts
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'
Date mode and dateInZone

Instant: 2026-07-15T23:30:00+02:00

Date
Bound value:
2026-07-15T23:30:00+02:00
Date
Bound value:
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 ​

vue
<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 ​

vue
<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>

Released under the MIT License.