let now = new Date();
// 月份从0开始
let month = new Date().getMonth() + 1
let format_month = ("0" + month).slice(-2);
console.log(format_month);
// 02
参考
javascript 月份两位表示
js:Date获取月份格式化为2位
阅读 49
2022-03-15
let now = new Date();
// 月份从0开始
let month = new Date().getMonth() + 1
let format_month = ("0" + month).slice(-2);
console.log(format_month);
// 02
参考
javascript 月份两位表示
相关推荐
精彩评论(0)