Get Input Datetime Local - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local


The Input DatetimeLocal object represents an HTML <input> element with type="datetime-local".

You can access an <input> element with type="datetime-local" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="datetime-local" id="myLocalDate" value="2014-11-16T15:25:33">

<button onclick="myFunction()">get the local date and time of the datetime field</button>

<p id="demo"></p>

function myFunction() {/* www  .ja  v  a m*/
    var x = document.getElementById("myLocalDate").value;
    document.getElementById("demo").innerHTML = x;

Related Tutorials