Calculate Time Difference with JavaScript

后端 未结 12 1141
有刺的猬
有刺的猬 2020-12-01 13:20

I have two HTML input boxes, that need to calculate the time difference in JavaScript onBlur (since I need it in real time) and insert the result to new input box.

F

12条回答
  •  执念已碎
    2020-12-01 13:47

    Try This

    var dif = ( new Date("1970-1-1 " + end-time) - new Date("1970-1-1 " + start-time) ) / 1000 / 60 / 60;
    

提交回复
热议问题