JavaScript Code


JavaScript – Get Month from Date


Date – getMonth()

date.getMonth()

getMonth() returns an integer representing the month of this date object. 0 is January, 1 is February, 2 is March, and so on

Examples

1. get the month from current date

let date = new Date();
console.log(date);
console.log(date.getMonth());


Copyright @2022