I'm trying to calculate time locally on the client machine to specify the ending time of a certain promotion. I do so by using the following code:
var targetDate = new Date(1442055673000);
var currentDate = new Date;
setInterval(updateTime, 1000);
function updateTime() {
var diff = new Date(targetDate - new Date());
var days = diff.getUTCDay();
var hours = diff.getUTCHours();
var minutes = diff.getUTCMinutes();
var seconds = diff.getUTCSeconds();
console.log(days + " : " + hours + " : " + minutes + " : " + seconds);}
The date at which the promotion ends is 09.12.2015 and today is 09.09.2015. For whatever reason the difference is calculated incorrectly (it shows that the difference is 6 days instead of 3).