0
如果在指定日期和今天的日期之間有42天或更長時間,我正在讀取日期輸入的值並需要鍛鍊。這是我到目前爲止已經試過:獲取指定日期之前的天數Javascript
var sdate = new Date($("#holiday-editor input[name=StartDate]").val()); //This is returing date in the string format
var priorDate = new Date().setDate(sdate - 42).toString(); // This is returning some abstract int value
var dateNow = new Date().getDate().toString(); // this is returning 5 even though I'd like to get today's date in the string format
if (dateNow > priorDate) {
$("#HolidayBookedLate").show();
}
有許多重複,[*挑選一個*](http://stackoverflow.com/search?q=%5Bjavascript%5D+difference+in+days+between+dates)。 – RobG