Overview
TheDateTimePicker class provides a combined date and time selection interface. It offers extensive customization options including date constraints, custom labels, display format, clock picker mode, and orientation.
Inheritance
Constructor
Parameters
The unique identifier for the date-time picker node in the DOM.
The placeholder text to display when no date-time is selected.
The initial date-time value. Can be a Date object, string, or timestamp.
The date format to display selected dates. Example:
'dd-MM-yyyy 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 date-time picker is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the picker.
Action(s) to execute when a date-time is selected.
The minimum selectable date. Dates before this will be disabled.
The maximum selectable date. Dates after this will be disabled.
Custom label for the accept/confirm button.
Custom label for the cancel button.
Custom label for the select time action.
Custom label for the enter time action.
Whether to show the clock picker interface for time selection.
The orientation of the picker dialog.
Properties
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier for the node |
placeholder | string | The placeholder text |
type | 'datetime' | The node type (read-only) |
value | any | The selected date-time value |
readOnly | boolean | Whether the input field is read-only |
dateFormat | string | Display format for dates |
minDate | Date | Minimum selectable date |
maxDate | Date | Maximum selectable date |
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 |
orientation | 'portrait' | 'landscape' | Picker dialog orientation |
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
Date Format Patterns
ThedateFormat property accepts standard date format patterns:
| Pattern | Description | Example |
|---|---|---|
yyyy | 4-digit year | 2024 |
yy | 2-digit year | 24 |
MM | 2-digit month | 03 |
MMM | Short month name | Mar |
MMMM | Full month name | March |
dd | 2-digit day | 05 |
d | 1-2 digit day | 5 |
HH | 24-hour format | 14 |
hh | 12-hour format | 02 |
mm | Minutes | 30 |
ss | Seconds | 45 |
a | AM/PM marker | PM |
Example Formats
Clock Picker Mode
WhenshowClockPicker is true, users can select time using an analog clock interface:
Orientation
The picker dialog can be displayed in portrait or landscape mode:Related Node Types
- DatePicker - For selecting date only
- TimePicker - For selecting time only
- DateRangePicker - For selecting a date range
- Input - Base input node for text values
