×

Please give details of the problem

Skip to content

How to deal with a date

Check if a date is in the future

function isDateFuture(date_number_sec) {
    var asof_now = new Date();  
    //get time today 00.00  
    var asof_today_midnight = new Date(asof_now.getFullYear(), asof_now.getMonth(), asof_now.getDate());  
    var current_date_sec = parseInt(asof_today_midnight.getTime() / 1000);

    //get date input 00.00  
    var date_input = new Date(date_number_sec * 1000);  
    var date_input_midnight = new Date(date_input.getFullYear(), date_input.getMonth(), date_input.getDate());  
    var date_input_midnight_sec = parseInt(date_input_midnight.getTime() / 1000);

    return (date_input_midnight_sec >= current_date_sec);  
} 

Example

isDateFuture(1723333825);
//Expected result: true

How to initialize a widget date with the current date

my_date = new Date();  
currentTime = Math.round(my_date.getTime()/ 1000);  
RMPApplication.setVariable("my_widget_date_variable",currentTime);