Get the time difference between two datetimes

前端 未结 19 2415
花落未央
花落未央 2020-11-22 05:25

I know I can do anything and some more envolving Dates with momentjs. But embarrassingly, I\'m having a hard time trying to do something that seems simple: geting the differ

19条回答
  •  感动是毒
    2020-11-22 06:00

    InTime=06:38,Outtime=15:40

     calTimeDifference(){
            this.start = dailyattendance.InTime.split(":");
            this.end = dailyattendance.OutTime.split(":");
            var time1 = ((parseInt(this.start[0]) * 60) + parseInt(this.start[1]))
            var time2 = ((parseInt(this.end[0]) * 60) + parseInt(this.end[1]));
            var time3 = ((time2 - time1) / 60);
            var timeHr = parseInt(""+time3);
            var  timeMin = ((time2 - time1) % 60);
        }
    

提交回复
热议问题