Skip to main content
← πŸ“„ HTML & the platformΒ·Module A3 Β· Lesson 4
TaskBuild an event form: <input name='date' type='date' min='2026-01-01'> and <input name='time' type='time'>.

Date/time inputs

75 XP7 min
Theory

Native pickers β€” no jQuery datepicker needed

<input type="date" name="dob" />                  <!-- 2026-05-20 -->
<input type="time" name="alarm" />                <!-- 14:30 -->
<input type="datetime-local" name="meeting" />    <!-- 2026-05-20T14:30 -->
<input type="month" name="month" />               <!-- 2026-05 -->
<input type="week" name="week" />                 <!-- 2026-W21 -->

Every modern browser ships a calendar/clock picker. The user types or picks; the value submitted is ISO 8601.

ISO 8601 is the only format

Don't put format hints in placeholders like "MM/DD/YYYY". The browser localizes display to the user's locale automatically β€” they see "May 20, 2026" in en-US, "20 Mai 2026" in de-DE, "20/05/2026" in en-GB. The value that gets posted is always YYYY-MM-DD.

min and max work

<input type="date" name="dob" max="2026-05-20" />   <!-- can't pick a future date -->
<input type="date" name="appt" min="2026-06-01" max="2026-12-31" />

datetime-local has no timezone

The submitted value is 2026-05-20T14:30 with no Z or offset. The browser sends it in the user's local time, and your backend must store the user's timezone separately (or assume UTC). Use type="datetime-local" for "wall clock" times (meetings, alarms) and a server-side picker for absolute UTC instants.

πŸ”’

Sign up to start coding

Theory is open to everyone. The interactive editor, live preview, and check are unlocked with a 7-day free trial β€” card required, cancel anytime.

Sign up β€” free trial β†’

First 10 lessons in each track are free. No card needed for those.

← PreviousNext lesson β†’

Get one Python or web tip a day β€” by email

Short, hand-written, no spam. Unsubscribe in one click.