<secure-datetime>
Date, time, and datetime inputs with range validation, timezone handling, and format normalization.
Overview
The <secure-datetime> component provides secure date and time inputs with automatic format validation, range checking, and consistent output format regardless of browser locale.
Input Types
Date, Time, and DateTime HTML
<!-- Date only -->
<secure-datetime
type="date"
label="Date of Birth"
name="dob"
security-tier="sensitive"
required
></secure-datetime>
<!-- Time only -->
<secure-datetime
type="time"
label="Appointment Time"
name="appointment_time"
security-tier="authenticated"
></secure-datetime>
<!-- Date and Time -->
<secure-datetime
type="datetime-local"
label="Event Start"
name="event_start"
security-tier="public"
></secure-datetime>
<!-- Month picker -->
<secure-datetime
type="month"
label="Expiration"
name="card_expiry"
security-tier="critical"
></secure-datetime>Live Demo
Validation
Date Range Constraints
Min/Max Dates HTML
<!-- Date of birth: must be at least 18 years ago -->
<secure-datetime
type="date"
label="Date of Birth"
name="dob"
max="2006-01-01"
security-tier="sensitive"
></secure-datetime>
<!-- Future date only -->
<secure-datetime
type="date"
label="Appointment Date"
name="appointment"
min="2024-01-01"
security-tier="authenticated"
></secure-datetime>
<!-- Time range (business hours) -->
<secure-datetime
type="time"
label="Meeting Time"
name="meeting_time"
min="09:00"
max="17:00"
step="1800"
></secure-datetime>API Reference
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
type | string | "date" | date, time, datetime-local, month, week |
security-tier | string | "critical" | Security level |
name | string | - | Form field name |
label | string | - | Accessible label |
min | string | - | Minimum date/time |
max | string | - | Maximum date/time |
step | number | - | Step interval (seconds for time) |
required | boolean | false | Field is required |
disabled | boolean | false | Disable input |
Properties
value string ISO format date/time value
valid boolean Validation state
Methods
getValueAsDate(): Date | null
Returns the current value as a JavaScript Date object, or null if empty or invalid
Events
| Event | Detail | Description |
|---|---|---|
secure-datetime-change | | Fired on value change. The raw value is intentionally absent — read it from e.target.value. |