我有一个函数,我想用它来使用这个布尔函数将数据分成列表

时间:2018-01-20 17:40:16

标签: javascript date boolean tablerow

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中使用它?

1 个答案:

答案 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
}