new Date(7 numbers)

Using new Date(7 numbers), creates a new date object with the specified date and time. The 7 numbers specify the year, month, day, hour, minute, second, and millisecond, in that order:

HTML file: Displayed by browser:
<body>
<p>Using new Date(7 numbers):</p>
<p id="demo"></p>
<hr />
<p>Variants of the example above let us omit any of the last 4 parameters:</p>
<p id="demo1"></p>

<script>
var d = new Date(99,5,24,11,33,30,0);
var e = new Date(99,5,24);
document.getElementById("demo").innerHTML = d;
document.getElementById("demo1").innerHTML = e;
</script>
</body>

Using new Date(7 numbers):


Variants of the example above let us omit any of the last 4 parameters:

JavaScript counts months from 0 to 11. January is 0. December is 11.

BackTable of ContentsNext