Reference JavaScript reference

Date.prototype.getMonth 参考

Date.prototype.getMonth Reference,整理语法、参数、示例、返回值和常见错误,适合快速查询 JavaScript 写法。

语法

js
const result = date.getMonth();

参数

  • value:日期字符串、时间戳或年/月/日参数。
  • locales / options:格式化方法可选的本地化配置。

返回值

返回时间戳、日期字段或格式化后的字符串。

示例

js
const date = new Date("2026-09-28T08:00:00+08:00");
console.log(date.getMonth());

常见错误

  • 日期字符串没有时区时,跨环境解析结果可能不同。

相关内容