HTML5 Datetime-local Input Type

The datetime-local type is used to specify the both date and time. It displays the complete particular date (year, month and date) and time(hour and minute). It is in 12 hour format, so the user also have to set AM or PM while setting the time. The datetime-local type is used in <input> tag.

Syntax of Datetime-local Input Type

<input type= "datetime-local">

Browser Support

The datetime-local input type is supported by Google Chrome, Safari and Opera.

HTML5 datetime-local Input Type Example

<!DOCTYPE html>
		Appointment to the Doctor :<input type="datetime-local" >

  • Here in this program we have to set both date and time with AM & PM by using datetime-local type in input tag.
  • <input type=”datetime-local” > is used for datetime-local type.

HTML5 Datetime-local Demo

  • Save the file as datetime-local_example.html in your system.
  • Just open the file in the browser, you will see the below picture in the browser.
    Note that the browser must support HTML5 specification.

When the execution process is completed successfully we will get the following output:

HTML5 Datetime-local Input Type
Here we can set the complete date and time of 12 hour format.



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.