当我们在date对象上调用getMonth()getDate()时,我们会得到个位数。 例如:

对于january,它显示1,但我需要显示为01。该怎么做?

var d = new Date(); 

日期格式化:
("0" + d.getDate()).slice(-2)
月份格式化:
("0" + (this.getMonth() + 1)).slice(-2)

作者 admin

百度广告效果展示