i.e. I want to calculate the time difference from 8.30pm to 9pm in 24hr format. so far i have:
let start = 2030;
let end = 2100;
let timeDiff = end - start;
But this gives me 70 as an answer. How do I get 30 minutes as an answer?
i.e. I want to calculate the time difference from 8.30pm to 9pm in 24hr format. so far i have:
let start = 2030;
let end = 2100;
let timeDiff = end - start;
But this gives me 70 as an answer. How do I get 30 minutes as an answer?
You need to specify the correct format of your time. you can calculate like below.
let start = new Date('1900/01/01 08:30 PM');
let end = new Date('1900/01/01 09:00 PM');
let minDiff = (Math.abs(start - end) / 1000)/60;
let hourDiff = ((Math.abs(start - end) / 1000)/60)/60;
let dayDiff = parseInt((((Math.abs(start - end) / 1000)/60)/60)/24);