new date jquery code example

Example 1: new date parameters javascript

// new Date parameters in javascript
new Date(year, month, date, hours, minutes, seconds, ms)

Example 2: new date() javascript

var date = new Date(); //Will use computers date by default.
//parameters will specify date you put to input
var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);

Example 3: display date in javascript

<button onclick="displayDate()">The time is?</button>

<script>
function displayDate() {
  document.getElementById("demo").innerHTML = Date();
}
</script>

Tags:

Html Example