How to use datetime input type in HTML?

The datetime input type is used in HTML using the <input type="datetime-local">. Using this, allow the users to select date and time. A date time picker popup is visible whenever input field is clicked.

Note − The input type datetime is not supported in Firefox and Internet Explorer. It works on Google Chrome.


You can try to run the following code to learn how to use datetime input type in HTML.

<!DOCTYPE html>
      <title>HTML input datetime</title>
      <form action = "" method = "get">
         Student Name<br><input type="name" name="sname"><br>
         Exam Date and Time<br><input type="datetime-local" name="datetime"><br>
         <input type="submit" value="Submit">

Updated on: 14-Sep-2023

26K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started