I have 2 Date Pickers and a blank text element on the screen
-
Calculate the difference (number of days) between the 2 date pickers
-
Multiply the difference by 60 and show in the text element
This is the code I’m using but its not…
$w.onReady( function () {
getDates();
});
export function date_diff_indays() {
let dt1 = new Date($w("#datePicker1"));
let dt2 = new Date($w("#datePicker2"));
return Math.floor((Date.UTC(dt2.getFullYear(), dt2.getMonth(), dt2.getDate()) - Date.UTC(dt1.getFullYear(), dt1.getMonth(), dt1.getDate()) ) /(1000 * 60 * 60 * 24));
}
function getDates(){
let diff = date_diff_indays();
const rates = (Number(diff)*60);
$w("#price1").text = String(rates);
}
export function datePicker1_change(event, $w) {
let date1 = $w("#datePicker1").value;
getDates();
}
export function datePicker2_change(event, $w) {
let date2 = $w("#datePicker2").value;
getDates();
}