Get the month, according to universal time:
const d = new Date();
let month = d.getUTCMonth();
Try it Yourself »
Get the name of the month (not just a number):
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const d = new Date()
let month = month[d.getUTCMonth()];
Try it Yourself »
getUTCMonth()
returns the month (0 to 11) of a date.
getUTCMonth()
returns the month according to UTC.
January = 0, February = 1, ... (See below):
UTC (Universal Time Coordinated) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All JavaScript getUTC methods assume that the date is of local time.
Date.getUTCMonth()
NONE |
Type | Description |
A number | The month of the date (0 to 11). |
getUTCMonth()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!