Javascript DOM HTML Input DatetimeLocal Object get

Introduction

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

Firefox does not support this control.

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

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="datetime-local" id="myLocalDate" value="2014-11-16T15:25:33">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from www.  java2 s .co m*/
  var x = document.getElementById("myLocalDate").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related