Header Ads

JavaScript Instance Methods in Date Object

JavaScript Instance Methods in Date Object
1.Get Date :
const date = new Date().getDate();
console.log(date);
Returns an integer number between 1 and 31 representing the day of the month for the given date according to local time. 

2.Get Day :
const day = new Date().getDay();
console.log(day);
Returns an integer number between 0 and 6 corresponding to the day of the week for the given date 0 for Sunday,1 for Monday, 2 for Tuesday, and so on. 

3.Get Month :
const month = new Date().getMonth();
console.log(month);
Returns an integer number between 0 and 11 representing the month in the given date according to local time. 0 corresponds to January, 1 to February and so on.

4.Get Hours :
const hour = new Date().getHours();
console.log(hour);
Returns an integer number between 0 and 23 representing the given date according to local time. 

5.Get Minutes :
const minutes = new Date().getMinutes();
console.log(minutes);
Returns an integer number between 0 and 59 representing the minutes in the given date according to local time.

No comments:

Powered by Blogger.