JavaScript添加到目前為止的前導零我創建這個腳本是為了提前10天以dd/mm/yyy格式計算日期:var MyDate = new Date();var MyDateString = new Date();MyDate.setDate(MyDate.getDate()+10);MyDateString = MyDate.getDate()
+ '/' + (MyDate.getMonth()+1) + '/' + MyDate.getFullYear();通過將這些規則添加到腳本中,我需要在日期和月份組件上顯示帶前導零的日期。我似乎不能讓它起作用。if (MyDate.getMonth < 10)getMonth = '0' + getMonth;和if (MyDate.getDate <10)get.Date = '0' + getDate;如果有人能告訴我把這些插入到腳本中的位置,我會非常感激的。
JavaScript添加到目前為止的前導零
郎朗坤
2019-06-20 16:21:44