Date Time Picker
- Common Input Field Features
- Step
- Auto Open
- Validation
- Week Numbers
- Initial Position
- Internationalization (i18n)
- Usage Patterns
- Best Practices
- Related Components
Date Time Picker is an input field for selecting both a date and a time.
The date and time can be entered directly using the keyboard in the format of the current locale or through the Date Time Picker’s two overlays. The overlays open when their respective fields are clicked or any input is entered when the fields are focused.
Common Input Field Features
Date Time Picker includes all Text Field and shared input field features.
Step
Date Time Picker’s step parameter defines the time interval (in seconds) between the items displayed in the time picker overlay. It also specifies the amount by which the time increases/decreases using the up/down arrow keys (when the overlays are disabled).
The default step is one hour (that is, 3600
).
Unlike with Number Field, Date Time Picker accepts values that don’t align with the specified step.
Note
|
Use even steps
The step must divide an hour or day evenly.
For example, "15 minutes", "30 minutes" and "2 hours" are valid steps, while "42 minutes" isn’t.
|
The displayed time format changes based on the step.
Step | Format |
---|---|
Less than 60 seconds | HH:MM:SS |
Less than 1 second | HH:MM:SS:FFF |
Note
|
Limit the number of steps
The overlay doesn’t appear for steps less than 900 seconds (15 minutes) to avoid showing an impractical number of choices.
|
Auto Open
The overlay opens automatically when the field is focused using a pointer (mouse or touch), or when the user types in the field. You can disable this, so that the overlay opens only when the toggle button or up/down arrow keys are pressed.
Validation
Week Numbers
You can configure Date Time Picker to show week numbers in the date picker overlay.
The week numbers are displayed according to ISO-8601. They can only be displayed when the first day of the week is Monday.
Initial Position
Date Time Picker’s initial position parameter defines which date is focused in the calendar overlay when the overlay is opened. Use this feature to minimize the need for any additional navigation and/or scrolling when the user’s input is expected to be between certain dates.
Internationalization (i18n)
Date Time Picker allows localizing texts and labels, such as month names and button labels.
new tab
Source code
date-time-picker-internationalization.ts
DateTimePickerInternationalization.java
See also how to configure a custom date format.
Usage Patterns
Best Practices
Use Date Time Picker when the user needs to choose both a date and time of day. If you only need a date or time of day, use Date Picker or Time Picker respectively.
Picking vs Typing
The calendar overlay is useful when the user needs to choose a day that’s close to the current date or when information such as day of the week, week number, valid dates, and so on, can aid in choosing the best option.
For days well into the past or future, and for known dates such as birthdays, typing the date can be a faster and easier approach. It’s important to verify that the user can enter dates according to their locale.