alpha

DateField

DateFields allow users to enter and edit date and time values using a keyboard. Each part of a date value is displayed in an individually editable segment.

installyarn add @react-spectrum/datepicker
version3.0.0-alpha.5
usageimport {DateField} from '@react-spectrum/datepicker'

Example#


<DateField label="Event date" />
<DateField label="Event date" />
<DateField label="Event date" />

Value#


A DateField displays a placeholder date by default. An initial, uncontrolled value can be provided to the DateField using the defaultValue prop. Alternatively, a controlled value can be provided using the value prop.

Date values are provided using objects in the @internationalized/date package. This library handles correct international date manipulation across calendars, time zones, and other localization concerns. DateField supports values of the following types:

  • CalendarDate – a date without any time components. May be parsed from a string representation using the parseDate function. Use this type to represent dates where the time is not important, such as a birthday or an all day calendar event.
  • CalendarDateTime – a date with a time, but not in any specific time zone. May be parsed from a string representation using the parseDateTime function. Use this type to represent times that occur at the same local time regardless of the time zone, such as the time of New Years Eve fireworks which always occur at midnight. Most times are better stored as a ZonedDateTime.
  • ZonedDateTime – a date with a time in a specific time zone. May be parsed from a string representation using the parseZonedDateTime, parseAbsolute, or parseAbsoluteToLocal functions. Use this type to represent an exact moment in time at a particular location on Earth.
import {parseDate} from '@internationalized/date';

function Example() {
  let [value, setValue] = React.useState(parseDate('2020-02-03'));

  return (
    <Flex gap="size-150" wrap>
      <DateField
        label="Date (uncontrolled)"
        defaultValue={parseDate('2020-02-03')} />
      <DateField
        label="Date (controlled)"
        value={value}
        onChange={setValue} />
    </Flex>
  );
}
import {parseDate} from '@internationalized/date';

function Example() {
  let [value, setValue] = React.useState(
    parseDate('2020-02-03')
  );

  return (
    <Flex gap="size-150" wrap>
      <DateField
        label="Date (uncontrolled)"
        defaultValue={parseDate('2020-02-03')}
      />
      <DateField
        label="Date (controlled)"
        value={value}
        onChange={setValue}
      />
    </Flex>
  );
}
import {parseDate} from '@internationalized/date';

function Example() {
  let [value, setValue] =
    React.useState(
      parseDate(
        '2020-02-03'
      )
    );

  return (
    <Flex
      gap="size-150"
      wrap
    >
      <DateField
        label="Date (uncontrolled)"
        defaultValue={parseDate(
          '2020-02-03'
        )}
      />
      <DateField
        label="Date (controlled)"
        value={value}
        onChange={setValue}
      />
    </Flex>
  );
}

Time zones#

DateField is time zone aware when a ZonedDateTime object is provided as the value. In this case, the time zone abbreviation is displayed, and time zone concerns such as daylight saving time are taken into account when the value is manipulated.

In most cases, your data will come from and be sent to a server as an ISO 8601 formatted string. @internationalized/date includes functions for parsing strings in multiple formats into ZonedDateTime objects. Which format you use will depend on what information you need to store.

  • parseZonedDateTime – This function parses a date with an explicit time zone and optional UTC offset attached (e.g. "2021-11-07T00:45[America/Los_Angeles]" or "2021-11-07T00:45-07:00[America/Los_Angeles]"). This format preserves the maximum amount of information. If the exact local time and time zone that a user selected is important, use this format. Storing the time zone and offset that was selected rather than converting to UTC ensures that the local time is correct regardless of daylight saving rule changes (e.g. if a locale abolishes DST). Examples where this applies include calendar events, reminders, and other times that occur in a particular location.
  • parseAbsolute – This function parses an absolute date and time that occurs at the same instant at all locations on Earth. It can be represented in UTC (e.g. "2021-11-07T07:45:00Z"), or stored with a particular offset (e.g. "2021-11-07T07:45:00-07:00"). A time zone identifier, e.g. America/Los_Angeles, must be passed, and the result will be converted into that time zone. Absolute times are the best way to represent events that occurred in the past, or future events where an exact time is needed, regardless of time zone.
  • parseAbsoluteToLocal – This function parses an absolute date and time into the current user's local time zone. It is a shortcut for parseAbsolute, and accepts the same formats.
import {parseZonedDateTime} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseZonedDateTime('2022-11-07T00:45[America/Los_Angeles]')}
/>
import {parseZonedDateTime} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseZonedDateTime(
    '2022-11-07T00:45[America/Los_Angeles]'
  )}
/>
import {parseZonedDateTime} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseZonedDateTime(
    '2022-11-07T00:45[America/Los_Angeles]'
  )}
/>

DateField displays times in the time zone included in the ZoneDateTime object. The above example is always displayed in Pacific Standard Time because the America/Los_Angeles time zone identifier is provided. @internationalized/date includes functions for converting dates between time zones, or parsing a date directly into a specific time zone or the user's local time zone, as shown below.

import {parseAbsoluteToLocal} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseAbsoluteToLocal('2021-11-07T07:45:00Z')}
/>
import {parseAbsoluteToLocal} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseAbsoluteToLocal(
    '2021-11-07T07:45:00Z'
  )}
/>
import {parseAbsoluteToLocal} from '@internationalized/date';

<DateField
  label="Event date"
  defaultValue={parseAbsoluteToLocal(
    '2021-11-07T07:45:00Z'
  )}
/>

Granularity#

The granularity prop allows you to control the smallest unit that is displayed by a DateField. By default, CalendarDate values are displayed with "day" granularity (year, month, and day), and CalendarDateTime and ZonedDateTime values are displayed with "minute" granularity. More granular time values can be displayed by setting the granularity prop to "second".

In addition, when a value with a time is provided but you wish to only display the date, you can set the granularity to "day". This has no effect on the actual value (it still has a time component), only on what fields are displayed. In the following example, two DateFields are synchronized with the same value, but display different granularities.

function Example() {
  let [date, setDate] = React.useState(
    parseAbsoluteToLocal('2021-04-07T18:45:22Z')
  );

  return (
    <Flex gap="size-150" wrap>
      <DateField
        label="Date and time"
        granularity="second"
        value={date}
        onChange={setDate}
      />
      <DateField
        label="Date"
        granularity="day"
        value={date}
        onChange={setDate}
      />
    </Flex>
  );
}
function Example() {
  let [date, setDate] = React.useState(
    parseAbsoluteToLocal('2021-04-07T18:45:22Z')
  );

  return (
    <Flex gap="size-150" wrap>
      <DateField
        label="Date and time"
        granularity="second"
        value={date}
        onChange={setDate}
      />
      <DateField
        label="Date"
        granularity="day"
        value={date}
        onChange={setDate}
      />
    </Flex>
  );
}
function Example() {
  let [date, setDate] =
    React.useState(
      parseAbsoluteToLocal(
        '2021-04-07T18:45:22Z'
      )
    );

  return (
    <Flex
      gap="size-150"
      wrap
    >
      <DateField
        label="Date and time"
        granularity="second"
        value={date}
        onChange={setDate}
      />
      <DateField
        label="Date"
        granularity="day"
        value={date}
        onChange={setDate}
      />
    </Flex>
  );
}

If no value or defaultValue prop is passed, then the granularity prop also affects which type of value is emitted from the onChange event. Note that by default, time values will not have a time zone because none was supplied. You can override this by setting the placeholderValue prop explicitly. Values emitted from onChange will use the time zone of the placeholder value.

import {now} from '@internationalized/date';

<Flex gap="size-150" wrap>
  <DateField
    label="Event date"
    granularity="second" />
  <DateField
    label="Event date"
    placeholderValue={now('America/New_York')}
    granularity="second" />
</Flex>
import {now} from '@internationalized/date';

<Flex gap="size-150" wrap>
  <DateField
    label="Event date"
    granularity="second" />
  <DateField
    label="Event date"
    placeholderValue={now('America/New_York')}
    granularity="second" />
</Flex>
import {now} from '@internationalized/date';

<Flex
  gap="size-150"
  wrap
>
  <DateField
    label="Event date"
    granularity="second"
  />
  <DateField
    label="Event date"
    placeholderValue={now(
      'America/New_York'
    )}
    granularity="second"
  />
</Flex>

International calendars#

DateField supports selecting dates in many calendar systems used around the world, including Gregorian, Hebrew, Indian, Islamic, Buddhist, and more. Dates are automatically displayed in the appropriate calendar system for the user's locale. The calendar system can be overridden using the Unicode calendar locale extension, passed to the Provider component.

Selected dates passed to onChange always use the same calendar system as the value or defaultValue prop. If no value or defaultValue is provided, then dates passed to onChange are always in the Gregorian calendar since this is the most commonly used. This means that even though the user selects dates in their local calendar system, applications are able to deal with dates from all users consistently.

The below example displays a DateField in the Hindi language, using the Indian calendar. Dates emitted from onChange are in the Gregorian calendar.

import {Provider} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(null);
  return (
    <Provider locale="hi-IN-u-ca-indian">
      <DateField label="Date" value={date} onChange={setDate} />
      <p>Selected date: {date?.toString()}</p>
    </Provider>
  );
}
import {Provider} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(null);
  return (
    <Provider locale="hi-IN-u-ca-indian">
      <DateField
        label="Date"
        value={date}
        onChange={setDate}
      />
      <p>Selected date: {date?.toString()}</p>
    </Provider>
  );
}
import {Provider} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] =
    React.useState(null);
  return (
    <Provider locale="hi-IN-u-ca-indian">
      <DateField
        label="Date"
        value={date}
        onChange={setDate}
      />
      <p>
        Selected date:
        {' '}
        {date
          ?.toString()}
      </p>
    </Provider>
  );
}

Labeling#


A visual label should be provided for the DateField using the label prop. If the DateField is required, the isRequired and necessityIndicator props can be used to show a required state.

<Flex gap="size-150" wrap>
  <DateField label="Birth date" />
  <DateField label="Birth date" isRequired necessityIndicator="icon" />
  <DateField label="Birth date" isRequired necessityIndicator="label" />
  <DateField label="Birth date" necessityIndicator="label" />
</Flex>
<Flex gap="size-150" wrap>
  <DateField label="Birth date" />
  <DateField
    label="Birth date"
    isRequired
    necessityIndicator="icon"
  />
  <DateField
    label="Birth date"
    isRequired
    necessityIndicator="label"
  />
  <DateField
    label="Birth date"
    necessityIndicator="label"
  />
</Flex>
<Flex
  gap="size-150"
  wrap
>
  <DateField label="Birth date" />
  <DateField
    label="Birth date"
    isRequired
    necessityIndicator="icon"
  />
  <DateField
    label="Birth date"
    isRequired
    necessityIndicator="label"
  />
  <DateField
    label="Birth date"
    necessityIndicator="label"
  />
</Flex>

Accessibility#

If a visible label isn't specified, an aria-label must be provided to the DateField for accessibility. If the field is labeled by a separate element, an aria-labelledby prop must be provided using the id of the labeling element instead.

Internationalization#

In order to internationalize a DateField, a localized string should be passed to the label or aria-label prop. When the necessityIndicator prop is set to "label", a localized string will be provided for "(required)" or "(optional)" automatically.

Events#


DateField accepts an onChange prop which is triggered whenever the date is edited by the user. The example below uses onChange to update a separate element with a formatted version of the date in the user's locale and local time zone. This is done by converting the date to a native JavaScript Date object to pass to the formatter.

import {getLocalTimeZone} from '@internationalized/date';
import {useDateFormatter} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(parseDate('1985-07-03'));
  let formatter = useDateFormatter({dateStyle: 'full'});

  return (
    <>
      <DateField label="Birth date" value={date} onChange={setDate} />
      <p>Selected date: {formatter.format(date.toDate(getLocalTimeZone()))}</p>
    </>
  );
}
import {getLocalTimeZone} from '@internationalized/date';
import {useDateFormatter} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(
    parseDate('1985-07-03')
  );
  let formatter = useDateFormatter({ dateStyle: 'full' });

  return (
    <>
      <DateField
        label="Birth date"
        value={date}
        onChange={setDate}
      />
      <p>
        Selected date:{' '}
        {formatter.format(date.toDate(getLocalTimeZone()))}
      </p>
    </>
  );
}
import {getLocalTimeZone} from '@internationalized/date';
import {useDateFormatter} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] =
    React.useState(
      parseDate(
        '1985-07-03'
      )
    );
  let formatter =
    useDateFormatter({
      dateStyle: 'full'
    });

  return (
    <>
      <DateField
        label="Birth date"
        value={date}
        onChange={setDate}
      />
      <p>
        Selected date:
        {' '}
        {formatter
          .format(
            date.toDate(
              getLocalTimeZone()
            )
          )}
      </p>
    </>
  );
}

Validation#


DateField can display a validation state to communicate to the user whether the current value is valid or invalid. Implement your own validation logic in your app and pass either "valid" or "invalid" via the validationState prop. The errorMessage prop can be used to communicate errors to the user.

This example validates that the selected date is a weekday and not a weekend according to the current locale.

import {today, isWeekend} from '@internationalized/date';
import {useLocale} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(today(getLocalTimeZone()));
  let {locale} = useLocale();

  return (
    <DateField
      label="Appointment date"
      value={date}
      onChange={setDate}
      validationState={isWeekend(date, locale) ? 'invalid' : 'valid'}
      description="Select a weekday"
      errorMessage="We are closed on weekends" />
  );
}
import {isWeekend, today} from '@internationalized/date';
import {useLocale} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] = React.useState(
    today(getLocalTimeZone())
  );
  let { locale } = useLocale();

  return (
    <DateField
      label="Appointment date"
      value={date}
      onChange={setDate}
      validationState={isWeekend(date, locale)
        ? 'invalid'
        : 'valid'}
      description="Select a weekday"
      errorMessage="We are closed on weekends"
    />
  );
}
import {
  isWeekend,
  today
} from '@internationalized/date';
import {useLocale} from '@adobe/react-spectrum';

function Example() {
  let [date, setDate] =
    React.useState(
      today(
        getLocalTimeZone()
      )
    );
  let { locale } =
    useLocale();

  return (
    <DateField
      label="Appointment date"
      value={date}
      onChange={setDate}
      validationState={isWeekend(
          date,
          locale
        )
        ? 'invalid'
        : 'valid'}
      description="Select a weekday"
      errorMessage="We are closed on weekends"
    />
  );
}

Minimum and maximum values#

The minValue and maxValue props can also be used to perform builtin validation. This displays an invalid state if the user enters an invalid date.

This example only accepts dates after today.

<DateField
  label="Appointment date"
  minValue={today(getLocalTimeZone())}
  defaultValue={parseDate('2022-02-03')} />
<DateField
  label="Appointment date"
  minValue={today(getLocalTimeZone())}
  defaultValue={parseDate('2022-02-03')} />
<DateField
  label="Appointment date"
  minValue={today(
    getLocalTimeZone()
  )}
  defaultValue={parseDate(
    '2022-02-03'
  )}
/>

Props#


NameTypeDefaultDescription
minValueDateValueThe minimum allowed date that a user may select.
maxValueDateValueThe maximum allowed date that a user may select.
isDateUnavailable( (date: DateValue )) => booleanCallback that is called for each date of the calendar. If it returns true, then the date is unavailable.
placeholderValueTA placeholder date to display when no value is selected. Defaults to today's date at midnight.
hourCycle1224Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale.
granularityGranularityDetermines the smallest unit that is displayed in the date picker. By default, this is "day" for dates, and "minute" for times.
hideTimeZonebooleanfalseWhether to hide the time zone abbreviation.
isDisabledbooleanWhether the input is disabled.
isReadOnlybooleanWhether the input can be selected but not changed by the user.
validationStateValidationStateWhether the input should display its "valid" or "invalid" visual styling.
isRequiredboolean

Whether user input is required on the input before form submission. Often paired with the necessityIndicator prop to add a visual indicator to the input.

autoFocusbooleanWhether the element should receive focus on render.
labelReactNodeThe content to display as the label.
descriptionReactNodeA description for the field. Provides a hint such as specific requirements for what to choose.
errorMessageReactNodeAn error message for the field.
valueTThe current value (controlled).
defaultValueTThe default value (uncontrolled).
isQuietbooleanfalseWhether the date picker should be displayed with a quiet style.
showFormatHelpTextbooleanfalseWhether to show the localized date format as help text below the field.
labelPositionLabelPosition'top'The label's overall position relative to the element it is labeling.
labelAlignAlignment'start'The label's horizontal alignment relative to the element it is labeling.
necessityIndicatorNecessityIndicator'icon'Whether the required state should be shown as an icon or text.
Events
NameTypeDefaultDescription
onFocus( (e: FocusEvent )) => voidHandler that is called when the element receives focus.
onBlur( (e: FocusEvent )) => voidHandler that is called when the element loses focus.
onFocusChange( (isFocused: boolean )) => voidHandler that is called when the element's focus status changes.
onKeyDown( (e: KeyboardEvent )) => voidHandler that is called when a key is pressed.
onKeyUp( (e: KeyboardEvent )) => voidHandler that is called when a key is released.
onChange( (value: <T> )) => voidHandler that is called when the value changes.
Layout
NameTypeDefaultDescription
flexResponsive<stringnumberboolean>When used in a flex layout, specifies how the element will grow or shrink to fit the space available. See MDN.
flexGrowResponsive<number>When used in a flex layout, specifies how the element will grow to fit the space available. See MDN.
flexShrinkResponsive<number>When used in a flex layout, specifies how the element will shrink to fit the space available. See MDN.
flexBasisResponsive<numberstring>When used in a flex layout, specifies the initial main size of the element. See MDN.
alignSelfResponsive<'auto''normal''start''end''center''flex-start''flex-end''self-start''self-end''stretch'>Overrides the alignItems property of a flex or grid container. See MDN.
justifySelfResponsive<'auto''normal''start''end''flex-start''flex-end''self-start''self-end''center''left''right''stretch'>Specifies how the element is justified inside a flex or grid container. See MDN.
orderResponsive<number>The layout order for the element within a flex or grid container. See MDN.
gridAreaResponsive<string>When used in a grid layout, specifies the named grid area that the element should be placed in within the grid. See MDN.
gridColumnResponsive<string>When used in a grid layout, specifies the column the element should be placed in within the grid. See MDN.
gridRowResponsive<string>When used in a grid layout, specifies the row the element should be placed in within the grid. See MDN.
gridColumnStartResponsive<string>When used in a grid layout, specifies the starting column to span within the grid. See MDN.
gridColumnEndResponsive<string>When used in a grid layout, specifies the ending column to span within the grid. See MDN.
gridRowStartResponsive<string>When used in a grid layout, specifies the starting row to span within the grid. See MDN.
gridRowEndResponsive<string>When used in a grid layout, specifies the ending row to span within the grid. See MDN.
Spacing
NameTypeDefaultDescription
marginResponsive<DimensionValue>The margin for all four sides of the element. See MDN.
marginTopResponsive<DimensionValue>The margin for the top side of the element. See MDN.
marginBottomResponsive<DimensionValue>The margin for the bottom side of the element. See MDN.
marginStartResponsive<DimensionValue>The margin for the logical start side of the element, depending on layout direction. See MDN.
marginEndResponsive<DimensionValue>The margin for the logical end side of an element, depending on layout direction. See MDN.
marginXResponsive<DimensionValue>The margin for both the left and right sides of the element. See MDN.
marginYResponsive<DimensionValue>The margin for both the top and bottom sides of the element. See MDN.
Sizing
NameTypeDefaultDescription
widthResponsive<DimensionValue>The width of the element. See MDN.
minWidthResponsive<DimensionValue>The minimum width of the element. See MDN.
maxWidthResponsive<DimensionValue>The maximum width of the element. See MDN.
heightResponsive<DimensionValue>The height of the element. See MDN.
minHeightResponsive<DimensionValue>The minimum height of the element. See MDN.
maxHeightResponsive<DimensionValue>The maximum height of the element. See MDN.
Positioning
NameTypeDefaultDescription
positionResponsive<'static''relative''absolute''fixed''sticky'>Specifies how the element is positioned. See MDN.
topResponsive<DimensionValue>The top position for the element. See MDN.
bottomResponsive<DimensionValue>The bottom position for the element. See MDN.
leftResponsive<DimensionValue>The left position for the element. See MDN. Consider using start instead for RTL support.
rightResponsive<DimensionValue>The right position for the element. See MDN. Consider using start instead for RTL support.
startResponsive<DimensionValue>The logical start position for the element, depending on layout direction. See MDN.
endResponsive<DimensionValue>The logical end position for the element, depending on layout direction. See MDN.
zIndexResponsive<number>The stacking order for the element. See MDN.
isHiddenResponsive<boolean>Hides the element.
Accessibility
NameTypeDefaultDescription
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
Advanced
NameTypeDefaultDescription
UNSAFE_classNamestringSets the CSS className for the element. Only use as a last resort. Use style props instead.
UNSAFE_styleCSSPropertiesSets inline style for the element. Only use as a last resort. Use style props instead.

Visual options#


Quiet#

<DateField label="Birth date" isQuiet />
<DateField label="Birth date" isQuiet />
<DateField
  label="Birth date"
  isQuiet
/>

Disabled#

<DateField label="Birth date" isDisabled />
<DateField label="Birth date" isDisabled />
<DateField
  label="Birth date"
  isDisabled
/>

Read only#

The isReadOnly boolean prop makes the DateField's value immutable. Unlike isDisabled, the DateField remains focusable.

<DateField label="Birth date" value={today(getLocalTimeZone())} isReadOnly />
<DateField
  label="Birth date"
  value={today(getLocalTimeZone())}
  isReadOnly
/>
<DateField
  label="Birth date"
  value={today(
    getLocalTimeZone()
  )}
  isReadOnly
/>

Label alignment and position#

View guidelines

By default, the label is positioned above the DateField. The labelPosition prop can be used to position the label to the side. The labelAlign prop can be used to align the label as "start" or "end". For left-to-right (LTR) languages, "start" refers to the left most edge of the DateField and "end" refers to the right most edge. For right-to-left (RTL) languages, this is flipped.

<DateField label="Birth date" labelPosition="side" labelAlign="end" />
<DateField
  label="Birth date"
  labelPosition="side"
  labelAlign="end"
/>
<DateField
  label="Birth date"
  labelPosition="side"
  labelAlign="end"
/>

Help text#

View guidelines

Both a description and an error message can be supplied to a DateField. The description is always visible unless the validationState is “invalid” and an error message is provided. The error message can be used to help the user fix their input quickly and should be specific to the detected error. All strings should be localized. See the Validation section above for an example.

DateField also supports displaying the expected date format for the user's locale automatically using the showFormatHelpText prop.

<DateField label="Birth date" showFormatHelpText />
<DateField label="Birth date" showFormatHelpText />
<DateField
  label="Birth date"
  showFormatHelpText
/>

Placeholder value#

When no value is set, a placeholder value is shown. By default, this is today's date at midnight. However, this can be overridden by setting the placeholderValue prop to a more appropriate placeholder for your specific usecase.

import {CalendarDate} from '@internationalized/date';

<DateField
  label="Birth date"
  placeholderValue={new CalendarDate(1980, 1, 1)}
/>
import {CalendarDate} from '@internationalized/date';

<DateField
  label="Birth date"
  placeholderValue={new CalendarDate(1980, 1, 1)}
/>
import {CalendarDate} from '@internationalized/date';

<DateField
  label="Birth date"
  placeholderValue={new CalendarDate(
    1980,
    1,
    1
  )}
/>

Hide time zone#

When a ZonedDateTime object is provided as the value of a DateField, the time zone abbreviation is displayed by default. However, if this is displayed elsewhere or implicit based on the usecase, it can be hidden using the hideTimeZone option.

<DateField
  label="Appointment time"
  defaultValue={parseZonedDateTime('2022-11-07T10:45[America/Los_Angeles]')}
  hideTimeZone />
<DateField
  label="Appointment time"
  defaultValue={parseZonedDateTime(
    '2022-11-07T10:45[America/Los_Angeles]'
  )}
  hideTimeZone
/>
<DateField
  label="Appointment time"
  defaultValue={parseZonedDateTime(
    '2022-11-07T10:45[America/Los_Angeles]'
  )}
  hideTimeZone
/>

Hour cycle#

By default, DateField displays times in either 12 or 24 hour hour format depending on the user's locale. However, this can be overridden using the hourCycle prop if needed for a specific usecase. This example forces the DateField to use 24-hour time, regardless of the locale.

<DateField
  label="Appointment time"
  granularity="minute"
  hourCycle={24} />
<DateField
  label="Appointment time"
  granularity="minute"
  hourCycle={24} />
<DateField
  label="Appointment time"
  granularity="minute"
  hourCycle={24}
/>