HTML – <input type=”datetime-local”>
The HTML <input> element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent.
one of them is <input type=”date”>
We don’t need any javascript plugin to show date time picker in forms. It now different types of date formats.
<input type=”date”>
Above input, the type will only show the date with the yyyy-mm-dd format but if you want to show time also then you have to use
<input type=”datetime-local”>
when we use the above method, input will show you date only on a small window, select any date, then the input will show value like
The — are a placeholder for time, select first — then use Up & Down arrows of input to change the hour and minutes.
The format shown on input is mm/dd/yyyy but when posting to the server it will always format the value like
yyyy-mm-dd
That’s it.
Glad you read all.




Leave a Reply