Date object in Javascript
Date object in Javascript
--It is a built-in object that represents a specific moment in time. You can create new instances of the `Date` object to work with different dates and times.
--For example, you can create a new `Date` object using the `new` keyword:
let currentDate = new Date();
console.log(currentDate) //2024-04-09T08:03:06.697Z
With the above example we can display the current date
JavaScript counts months from 0 to 11:
January = 0.
December = 11.
7 numbers specify year, month, day, hour, minute, second, and millisecond (in that order):
let birthday=new Date(2004,5,25,8,30);
console.log(birthday)
Some getter setter methods in javascript
console.log(birthday.getFullYear());
console.log(birthday.getDate());
console.log(birthday.getMonth());
console.log(birthday.getDay());
console.log(birthday.getHours());
console.log(birthday.getMinutes())
console.log(birthday.getSeconds())
/*
Output:
2004
25
5
5
8
30
0
*/