Overview
TheTimePicker class provides a time-only selection interface. It extends DateTimePicker but is configured specifically for time selection without date components.
Inheritance
Constructor
Parameters
The unique identifier for the time picker node in the DOM.
The placeholder text to display when no time is selected.
The initial time value. Can be a Date object, string, or timestamp.
The time format to display. Example:
'HH:mm' or 'hh:mm a'Whether to display the node in a single line layout.
Material icon name to display in the picker field.
Custom error message to display when validation fails.
Whether the time picker is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the picker.
Action(s) to execute when a time is selected.
The minimum selectable time (time component is used).
The maximum selectable time (time component is used).
Custom label for the accept/confirm button.
Custom label for the cancel button.
Properties
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier for the node |
placeholder | string | The placeholder text |
type | 'timepicker' | The node type (read-only) |
value | any | The selected time value |
readOnly | boolean | Whether the input field is read-only |
dateFormat | string | Display format for time |
minDate | Date | Minimum selectable time |
maxDate | Date | Maximum selectable time |
acceptLabel | string | Label for accept button |
cancelLabel | string | Label for cancel button |
selectTimeLabel | string | Label for select time action |
enterTimeLabel | string | Label for enter time action |
showClockPicker | boolean | Whether to show clock picker (inherited) |
orientation | 'portrait' | 'landscape' | Picker dialog orientation (inherited) |
singleLine | boolean | Whether displayed in single line layout |
icon | string | Material icon name |
errorMessage | string | Custom error message |
disabled | boolean | Whether the node is disabled |
validator | Validator | AbstractControlOptions | Synchronous validators |
asyncValidator | AsyncValidatorFn | Asynchronous validators |
action | Action | Action[] | Associated actions |
hint | string | Hint text to display |
autoFocus | boolean | Whether to auto-focus on load |
Methods
getNativeElement()
Returns the native DOM element for this node.Usage Example
Time Format Patterns
ThedateFormat property accepts time-specific format patterns:
| Pattern | Description | Example |
|---|---|---|
HH | 24-hour format (00-23) | 14 |
hh | 12-hour format (01-12) | 02 |
h | 12-hour format (1-12) | 2 |
mm | Minutes (00-59) | 30 |
ss | Seconds (00-59) | 45 |
a | AM/PM marker | PM |
A | AM/PM marker uppercase | PM |
Common Time Formats
Time Constraints
Business Hours Example
Restrict time selection to business hours:Time Intervals
While the time picker doesn’t directly support time intervals, you can validate selected times:Best Practices
When to Use TimePicker
- Time-only input: When you need time selection without a date
- Scheduling: For appointment times, reminder times, alarm times
- Duration selection: Start/end times within a day
- Time preferences: User settings for time-based features
Format Selection
- Use 12-hour format (
hh:mm a) for user-facing applications in regions that prefer it - Use 24-hour format (
HH:mm) for technical applications or international audiences - Consider locale preferences when setting the format
Inherited Features
SinceTimePicker extends DateTimePicker, it inherits additional properties that may be useful:
showClockPicker: Enable analog clock interfaceorientation: Set picker dialog orientationselectTimeLabel: Customize selection labelsenterTimeLabel: Customize entry labels
Related Node Types
- DateTimePicker - For selecting both date and time
- DatePicker - For selecting date only
- DateRangePicker - For selecting a date range
- Input - Base input node for text values
