0

calculation between two time slots, I retrieve a time from my database example: 11:50 and the current time is 18:50. How to calculate interval between the two schedules? thank you for help.

const currentTime = new Date();
    const timeMinutes = currentTime.getMinutes()
    
    if(timeMinutes < 10){
        var timeMinute = '0' + timeMinutes
    }else{
        timeMinute = timeMinutes
    }
const heureCommande = currentTime.getHours() + ":" + timeMinute
    console.log(heureCommande)
console.log(heureCommande - 18:50)
tony
  • 199
  • 4
  • 15
  • 3
    What is your expectation for `console.log(heureCommande - 18:50)`? – hoangdv May 09 '22 at 13:39
  • What does _"calculate interval"_ mean? An interval has a start and an end, e.g. `['11:50', '18:50']` could be considered an interval. What's the expected result? – jabaa May 09 '22 at 13:40
  • @hoangdv I would like to know the hour and minute difference between the two times – tony May 09 '22 at 13:48
  • @jabaa I would like to know the length of time between the two schedules – tony May 09 '22 at 13:49
  • Does this answer your question? [Check time difference in Javascript](https://stackoverflow.com/questions/1787939/check-time-difference-in-javascript#1788084) – jabaa May 09 '22 at 13:51
  • convert time into seconds. – vanowm May 09 '22 at 14:04

0 Answers0