let now = new Date();
// 月份从0开始
let month = new Date().getMonth() + 1
let format_month = ("0" + month).slice(-2);
console.log(format_month);
// 02
参考
javascript 月份两位表示
微信扫一扫
let now = new Date();
// 月份从0开始
let month = new Date().getMonth() + 1
let format_month = ("0" + month).slice(-2);
console.log(format_month);
// 02
参考
javascript 月份两位表示
相关推荐