我已经创建了这个脚本,以dd/mm/yyyy的格式提前10天计算日期:
var MyDate = new Date();
var MyDateString = new Date();
MyDate.setDate(MyDate.getDate()+10);
MyDateString = MyDate.getDate() + '/' + (MyDate.getMonth()+1) + '/' + MyDate.getFullYear();
Run Code Online (Sandbox Code Playgroud)
我需要通过将这些规则添加到脚本中,使日期和月份组件的日期显示为前导零.我似乎无法让它发挥作用.
if (MyDate.getMonth < 10)getMonth = '0' + getMonth;
Run Code Online (Sandbox Code Playgroud)
和
if (MyDate.getDate <10)get.Date = '0' + getDate;
Run Code Online (Sandbox Code Playgroud)
如果有人能告诉我将这些插入脚本的位置,我会非常感激.