📜  添加前导零 javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:33.313000             🧑  作者: Mango

代码示例6
var MyDate = new Date();
var MyDateString;

MyDate.setDate(MyDate.getDate() + 20);

MyDateString = ('0' + MyDate.getDate()).slice(-2) + '/'
             + ('0' + (MyDate.getMonth()+1)).slice(-2) + '/'
             + MyDate.getFullYear();