Javascript DOM HTML Input DatetimeLocal value Property get

Introduction

Get the local date and time of a datetime field:

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

Click the button to get the local date and time of the date time 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 w  ww .  j  a v  a2s.com*/
  var x = document.getElementById("myLocalDate").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related