The problem is your time zone.
When you execute new Date(difference) , you create a Date object that represents the moment of exatcly difference milliseconds after January 1, 1970. When you do lapse.getHours() , your time zone is used in the calculation. You cannot change your time zone through Javascript and you cannot change this behavior. Not without heavy Javascript tricks.
But your difference not a date, but a date difference. Treat as such, and calculate hours, minutes, and seconds, like this:
var hours = Math.floor(difference / 36e5), minutes = Math.floor(difference % 36e5 / 60000), seconds = Math.floor(difference % 60000 / 1000);
Alternatively, you can consider your time zone when creating lapse :
var lapse = new Date(difference + new Date().getTimezoneOffset() * 1000);
but I would not recommend this: Date objects are crowded for your purposes.
Maxart
source share