Date handling in JavaScript

Below lines of code illustrate how to work with date object in JavaScript.

console.log(Date())
var date = new Date();
console.log(“Day number in a month -> ” + date.getDate());
console.log(“Day number in a week -> ” + date.getDay());
console.log(“Current Month number -> ” + date.getMonth());
console.log(“Current Year -> ” + date.getFullYear());

console.log(“Current time -> ” + date.getTime());
console.log(“Current Hour time -> ” + date.getHours());
console.log(“Current Minutes time -> ” + date.getMinutes());
console.log(“Current Seconds time -> ” + date.getSeconds());
console.log(“Current Milli Seconds time -> ” + date.getMilliseconds());

You may also like...