📅

<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

AttributeTypeDefaultDescription
typestring"date"date, time, datetime-local, month, week
security-tierstring"critical"Security level
namestring-Form field name
labelstring-Accessible label
minstring-Minimum date/time
maxstring-Maximum date/time
stepnumber-Step interval (seconds for time)
requiredbooleanfalseField is required
disabledbooleanfalseDisable 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

EventDetailDescription
secure-datetime-change
 name, type, tier 
Fired on value change. The raw value is intentionally absent — read it from e.target.value.