var date = { isDuringDate: function (beginDateStr, endDateStr) { var curDate = new Date(), beginDate = new Date(beginDateStr), endDate = new Date(endDateStr); if (curDate >= beginDate && curDate <= endDate) { console.log("true") return true; } console.log("false") return false; } } date.isDuringDate('2020-09-17 13:00', '2021-09-17 15:00')