Calculate timespan in JavaScript

前端 未结 7 1982
刺人心
刺人心 2021-01-01 21:48

I have a .net 2.0 ascx control with a start time and end time textboxes. The data is as follows:

txtStart.Text = 09/19/2008 07:00:00

txtEnd.Text = 09/19/200

相关标签:
7条回答
  • 2021-01-01 22:16

    The answers above all assume string manipulation. Here's a solution that works with pure date objects:

    var start = new Date().getTime();
    window.setTimeout(function(){
      var diff = new Date(new Date().getTime() - start);
      // this will log 0 hours, 0 minutes, 1 second
      console.log(diff.getHours(), diff.getMinutes(),diff.getSeconds());
    },1000);
    
    0 讨论(0)
提交回复
热议问题