Чтобы достичь этого, вам нужно получить свои часы полета в допустимом типе строки, а затем создать из этой строки действительный объект даты, после чего вы можете вычесть время полета из текущего времени, если оно уже запланировано, выполучит положительное число.
Проверьте функцию ниже:
// try changing the flight_time to see if this works or not
var flight_time = '2018-10-28T20:20:30Z'; // assuming this is the flight time;
// now make a valid date format out of the given flight time;
var flight_hour = new Date(flight_time);
console.log(flight_hour)
var current_hour = new Date();
console.log(current_hour);
// now do the subtraction;
function calculate_hours() {
var difference = ((flight_hour - current_hour) / 3600000).toFixed(2);
document.getElementById('now').innerHTML = flight_hour.getHours();
document.getElementById('difference').innerHTML = difference;
console.log(difference) ;
}
calculate_hours();
<p> Now: <span id='now'></span></p>
<p> Difference: <span id='difference'></span></p>