JavaScript
x
3
1
date1=2023-01-02T12:22:00
2
date2=2023-01-03T22:15:00
3
How could I found the time difference?
Advertisement
Answer
JavaScript
1
12
12
1
function secondsToHMS(secs) {
2
function z(n){return (n<10?'0':'') + n;}
3
var sign = secs < 0 ? '-' : '';
4
secs = Math.abs(secs);
5
return sign + z(secs/3600 |0) + ':' + z((secs%3600) / 60 |0);
6
}
7
8
var d1 = new Date('2023-01-03T22:15:00');
9
var d2 = new Date('2023-01-02T12:22:00');
10
11
//console.log( secondsToHMS((d1 - d2) / 1000)); // 33:53
12