Get Input Datetime - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime


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>

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

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

Related Tutorials