Get Input Datetime - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime

Introduction

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

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime" id="myDatetime" value="2014-02-06T10:57Z">

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

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

<script>
function myFunction() {/*w ww  .  j  a  va 2 s. co m*/
    var x = document.getElementById("myDatetime").value;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials