Get Input Datetime Local - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local

Introduction

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>
<html>
<body>

<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>

<script>
function myFunction() {/* www  .ja  v  a 2s.co m*/
    var x = document.getElementById("myLocalDate").value;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials