Check time difference in Javascript

后端 未结 18 1128
梦毁少年i
梦毁少年i 2020-11-22 04:27

How would you check time difference from two text-boxes in Javascript?

18条回答
  •  隐瞒了意图╮
    2020-11-22 04:49

    In my case, I'm gonna store the time in milliseconds on chrome storage and try to find diff in hours later.

    function timeDiffInHours(milliseconds){
        time_diff = (new Date).getTime() - milliseconds
        return parseInt((time_diff/(1000*60*60)) % 24)
    }
    
    // This is again sending current time and diff would be 0.
    timeDiffInHours((new Date).getTime());  
    

提交回复
热议问题