Javascript DOM HTML Input Datetime Object get

Introduction

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

We can access an <input> element with type="datetime" via document.getElementById():

Click the button to get the date and time of the datetime field.

var x = document.getElementById("myDatetime");

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="datetime" id="myDatetime" value="2014-02-06T10:57Z">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {// w w w  .j  ava  2 s .c o m
  var x = document.getElementById("myDatetime").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related