Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Calendar
  2. Date Time Picker
  3. Usage

Date Time Picker

Usage

Overview

DateTimePicker from @prepared911/ui-calendar pairs a DatePicker with one or two native <input type="time"> fields. It ships in two modes—single and range—and supports deferred commits via onApply. Use it when a workflow commits a specific date-and-time (scheduling, appointment booking) rather than describing a query constraint.

For queries that need Before / After or half-open ranges, use AdvancedDateTimeRangePicker instead; DateTimePicker is designed for contiguous, "specific point or span" values.

SuMoTuWeThFrSa

When to use

  • Committed scheduled times. One-off appointments, single-shot reminders, and any workflow where the operator picks a date + time and saves it.
  • Range with maxRange enforcement. Shift-length constraints and other "no more than N days" rules are enforced by the component when maxRange is set.
  • Forms where both date and time matter equally. When time-of-day is essential rather than a refinement of a date, keep them together.

When not to use

  • Filter queries. Use AdvancedDateRangePicker / AdvancedDateTimeRangePicker: inequality semantics and committed ranges have different UX.
  • Date-only. Use DatePicker or DateInput: the time input adds cognitive load.
  • Time-only. Use TimePicker.
  • Repeating rules. Use EventRecurrencePicker.

Composition

  • Single mode. A DatePicker in Single mode stacked with a TimePicker (<input type="time">).
  • Range mode. A DatePicker in Range mode paired with TimeRangeInputs (a matched TimePicker pair with maxRange enforcement).
  • Optional Apply / Reset. onApply defers commits; without it, every change emits onChange.

Behavior and states

  • Deferred commits. With onApply, internal state tracks date and time drafts; Apply emits the committed value. Without it, onChange fires on every date or time change.
  • maxRange (range mode). When a range exceeds maxRange days, the component clamps the end to start + maxRange. Surface the limit in helper copy so the clamp is predictable.
  • Time zone. Values are Date objects. Convert at the boundary (convertLocalToUTC / convertUTCToLocal from @prepared911/util-helpers) so you store UTC and display local.
  • Partial selections. Range mode's onChange payload uses { start: Date | null; end: Date | null } so callers can observe mid-selection state; onApply is only dispatched on a full commit.

Best practices

Do

  • Store instants in UTC on the server and let the picker convert for display.
  • Pair onApply with deferred commits so mid-edit state does not fan out to network calls or dependent UI.
  • Surface maxRange limits in helper copy ("Shift length cannot exceed 12 hours") so the clamp feels intentional.
  • Reuse the same picker instance within a form rather than remounting between modes; internal state tracks drafts across control rerenders.

Don't

  • Don't use DateTimePicker for time-only changes to an existing date: a standalone TimePicker is less invasive.
  • Don't fake a range by mounting two Single pickers; the component handles end-before-start correction and the maxRange clamp in Range mode.
  • Don't mix DateTimePicker with a separate time selector bound to the same state: the internal TimePicker already owns time-of-day.

Accessibility

DateTimePicker inherits the date grid's keyboard semantics and the native time input's platform picker. The app owns the visible label for the time input (via TimePicker's label / hideLabel pattern), the Apply / Reset announcement if present, and distinct ids when multiple pickers share a screen. See the Accessibility page for the full contract.

Related

  • Date Picker: calendar grid alone.
  • Time Picker: time input alone.
  • Advanced Date Time Range Picker: inequality semantics with time.

Previous

Time Picker / Accessibility

Next

Date Time Picker / API and Development

On this page

Overview
When to use
When not to use
Composition
Behavior and states
Best practices
Accessibility
Related