function date_is_in_the_future(dateAdd){
// turn '2018-01-01' from a string to an object
input_date_object = new Date(dateAdd);
// Get todays date as an object
today_date = new Date();
// if the inpute_date_object is bigger than today_date, it will return false
boolean_result = input_date_object > today_date;
// return result
return boolean_result;
}
我需要对此功能做些什么才能在我的JavaScript中使用它?
答案 0 :(得分:0)
只需拨打电话;
console.log(date_is_in_the_future('2019-01-01'));
console.log(date_is_in_the_future('2017-01-01'));
function date_is_in_the_future(dateAdd){
//turn '2018-01-01' from a string to an object
input_date_object = new Date(dateAdd)
//Get todays date as an object
today_date = new Date()
//if the inpute_date_object is bigger than today_date, it will return false
boolean_result = input_date_object > today_date
//return result
return boolean_result
}