HTML time input: clear pickers for hours, minutes, and seconds
The HTML <input type="time">
provides a native picker for times of day. It outputs values in a predictable format (usually HH:MM
or HH:MM:SS
when seconds are enabled), which makes storage and comparison straightforward. Whether you are scheduling appointments, configuring reminders, or setting availability windows, the time input reduces formatting errors and speeds up entry across devices.
Granularity with step
By default, most browsers let users select hours and minutes. Add step
to control increments and enable seconds. For minute‑level selection use step="60"
; for 15‑minute slots, step="900"
; for per‑second precision, step="1"
. Match the step to your use case—finer precision than necessary makes pickers tedious, while overly coarse steps frustrate users who need exact values.
Constraints that make sense
Use min
and max
to restrict valid times, e.g., business hours 09:00
–18:00
. Communicate constraints in helper text so users understand why certain times are disabled.
Labeling & format
- Add a visible label like “Time” or “Appointment time”.
- Show an example format in helper text for browsers that fall back to manual entry.
- Clarify 12‑ vs 24‑hour expectations to avoid ambiguity.
Accessibility
- Ensure the picker opens via keyboard and that arrow keys adjust values.
- Associate errors with
aria-describedby
and keep messages concise. - Provide timezone context elsewhere if relevant; the control captures local time only.
Copy‑ready patterns
- Business hours:
min="09:00"
,max="18:00"
,step="900"
(15 minutes). - Alarm:
step="60"
with helper text indicating minutes. - Timer: enable seconds with
step="1"
and show the format.
Time inputs shine when paired with clear labels, sensible increments, and straightforward constraints. Keep logic about timezones and business rules on the server, and your users will enjoy a familiar, fast picker that prevents common formatting mistakes.