Calculate difference between 2 timestamps using javascript

前端 未结 3 816
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 17:25

I have to calculate the difference between 2 timestamps. Also can you please help me with conversion of a string into timestamp. Using plain javascript only. NO JQUERY.

3条回答
  •  醉话见心
    2020-12-14 17:29

    Based on the approved answer:

    function(timestamp1, timestamp2) {
        var difference = timestamp1 - timestamp2;
        var daysDifference = Math.floor(difference/1000/60/60/24);
    
        return daysDifference;
    }
    

提交回复
热议问题