// 获取当前日期的月份(注意:getMonth() 返回的月份是从 0 开始计数的,即 0 表示 1 月,11 表示 12 月)
const currentDate = new Date(); // 创建一个表示当前日期和时间的 Date 对象
const currentMonth = currentDate.getMonth(); // 获取当前月份,返回值是 0 到 11 之间的整数
console.log("当前月份(从 0 开始):", currentMonth);
// 如果你想得到实际的月份(1-12),可以加 1
const actualMonth = currentMonth + 1;
console.log("当前月份(1-12):", actualMonth);
下一篇:js onclick覆盖
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站