How do I get the difference between two Dates in JavaScript?

前端 未结 16 2392
北海茫月
北海茫月 2020-11-22 03:03

I\'m creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date.

16条回答
  •  误落风尘
    2020-11-22 04:01

    THIS IS WHAT I DID ON MY SYSTEM.

    var startTime=("08:00:00").split(":");
    var endTime=("16:00:00").split(":");
    var HoursInMinutes=((parseInt(endTime[0])*60)+parseInt(endTime[1]))-((parseInt(startTime[0])*60)+parseInt(startTime[1]));
    console.log(HoursInMinutes/60);
    

提交回复
热议问题