0
点赞
收藏
分享

微信扫一扫

js:Date获取月份格式化为2位


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 条评论