Hello.
I’m trying to understand why the following code assigns the value 2 to the hours.
I was expecting it to be 0:0:1 as I am just increasing the number of seconds by 1.
Instead, I am getting: 2:0:1
Any help would be appreciated
let from = new Date().getTime();
let to = from + 1000;
alert(format(to - from));
function format(timestamp) {
let date = new Date(timestamp);
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
return hours + ':' + minutes + ':' + seconds;
}