The getMonth() method is a method of the Date object in JavaScript. It is used to get the month part of the date object. The return value is an integer between 0 and 11, where 0 represents January and 1 represents February. And so on.
The usage is as follows:
var date = new Date(); var month = date.getMonth(); console.log(month); // 输出当前月份的数字
The above code will create a new Date object, then call the getMonth() method to get the number of the current month, and print the result to the console.
The above is the detailed content of How to use getmonth() method. For more information, please follow other related articles on the PHP Chinese website!