Aller au contenu principal
← 📄 HTML & the platform·Module A3 · Leçon 4
TâcheBuild an event form: <input name='date' type='date' min='2026-01-01'> and <input name='time' type='time'>.

Entrées date/heure

75 XP7 min
Théorie

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.

🔒

Inscris-toi pour coder

La théorie est ouverte à tous. L'éditeur, l'aperçu live et le check se débloquent avec un essai gratuit de 7 jours — carte requise, annulable à tout moment.

S'inscrire — essai gratuit →

Les 10 premières leçons de chaque parcours sont gratuites. Pas de carte requise.

← PrécédentLeçon suivante →

Recevez une astuce Python ou web par jour — par email

Court, écrit à la main, sans spam. Désabonnement en un clic.