Time Picker
The default field takes a 24-hour value in five minute steps. Type into it directly, or open the panel and pick each part.
Time Formats
One format string sets the display and the selectors the panel shows. Pick 12-hour for public-facing forms and 24-hour for operational tools.
Minute Steps
Set the minute list to the slots the service actually offers. The default step is five minutes.
Time Bounds and Validation
Limit the field to a working window. Options outside it are disabled, and a typed value outside it blocks the submit.
Built-in Features
Activates on any page carrying a .nds-time-input. The panel builds on first open, so a page of time fields costs nothing until one is used.
The field stays typeable. Entries such as 9:30 or 2:30 PM are accepted and padded on commit.
One format string sets both the visible text and which selectors the panel shows, so there is no separate mode flag to keep in sync.
Set the minute list to your real booking interval. A value that sits off the step grid keeps its own option rather than being rounded away.
Out-of-range options are disabled as you narrow the time, and a pick that falls out of range moves to the nearest allowed option instead of clearing.
A typed value is checked on change, so an unreadable or out-of-range time blocks the submit through the browser's own constraint validation.
Selector labels and the meridiem follow the page language and switch with it at runtime, while the submitted value stays unchanged.
Read and write the field from JavaScript with getValue, setValue and clear.
Usage Guidelines
Best Practices
- Use for any time of day: appointment slots, opening hours, shift starts, submission cut-offs
- For a date and a time together, place a Date Picker and a Time Picker as two fields. One field holding both is harder to correct when only the time is wrong
- Do not use for a duration such as two hours thirty minutes. A duration is a quantity, so use Text Inputs with number fields instead
- Choose
hh:mm Afor public-facing forms andHH:mmfor operational or internal tools - Add seconds only when the value needs them. Most appointment and opening-hour fields do not
- Set
data-stepto the interval the service offers. The default of five minutes already shortens the list, and a step of one renders sixty options - Read the value from the hidden
.nds-time-valuefield, or fromgetValue. The visible field holds localized display text - Write
data-min-timeanddata-max-timein 24-hour form whatever the display format is - Add
nds-darkerornds-lighterto the container for a filled field on a plain background
Data Attributes
| Attribute | Description |
|---|---|
data-format | Set on .nds-form-container. Tokens HH, H, hh, h, mm, ss, A, a. Any other character passes through as text. Lowercase hour tokens select 12-hour, and token presence decides which selectors the panel shows. Defaults to HH:mm |
data-step | Set on .nds-form-container. Minute interval for the minute list, from 1 to 60. Defaults to 5. Seconds always step by one |
data-required | Set on .nds-form-container. Marks the field required and blocks the submit while it is empty |
data-min-time | Set on .nds-time-input. Earliest allowed time, always 24-hour HH:mm or HH:mm:ss |
data-max-time | Set on .nds-time-input. Latest allowed time, same 24-hour form |
Value and Submission
The field has two inputs. The visible .nds-time-input is display text and carries no name, so it never submits. The hidden .nds-time-value carries the name and always holds a 24-hour value.
A 12-hour field showing 02:30 PM submits 14:30. The meridiem is a display choice and is never stored on its own, so the server reads the same value whatever language the page was in.
Both inputs dispatch native input and change events on every commit. The component dispatches no custom events, so listen on either input.
Keyboard
Type straight into the field. Alt plus ArrowDown opens the panel, where each selector behaves as a standard form select: Tab moves between them, Enter or Space opens a list, the arrow keys move through it, and Escape closes.
JavaScript API
The NDS.TimePicker API reads and writes the field in 24-hour form. Fields present at load initialize on their own. Call NDS.TimePicker.init() after injecting a field into the page.