print date in javascript code example
Example 1: javascript date
var d= new Date();
d.getFullYear();
d.getMonth();
d.getDate();
d.getHours();
d.getMinutes();
d.getSeconds();
d.getMilliseconds();
d.getTime();
Example 2: js get day month year
const d = new Date();
d.getMonth() + 1;
d.getDate();
d.getFullYear();
Example 3: new date parameters javascript
new Date(year, month, date, hours, minutes, seconds, ms)
Example 4: new date() javascript
var date = new Date();
var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);
Example 5: display date in javascript
<button onclick="displayDate()">The time is?</button>
<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>