# Thread: Why one extra hour in my countdown?

1. ## Why one extra hour in my countdown?

I tried to experiment with calculating days, hours, minutes, and seconds between current time and a future time. but I found I always got one extra hour,
does anyone know where the problem is?

Code:
```var date = new Date("12/21/2013 00:00:00 GMT-0500");
console.log(date);
var now = new Date();
console.log(nowf);
var timeDiff = date - now;
var days = Math.floor(timeDiff/(1000*60*60*24));
var hours = Math.floor((timeDiff%(1000*60*60*24))/(1000*60*60));
var minutes = Math.floor((timeDiff - (1000*60*60*24)*days - (1000*60*60)*hours)/(1000*60));
var seconds = Math.floor((timeDiff - (1000*60*60*24)*days - (1000*60*60)*hours - (1000*60)*minutes)/1000);
console.log(days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds!");```

2. date is GTB Daylight Time.
now is GTB Standard Time.
... or the other way around, depending on where you're asking.

Daylight and Standard time differ by an hour.

3. Originally Posted by myty
date is GTB Daylight Time.
now is GTB Standard Time.
... or the other way around, depending on where you're asking.

Daylight and Standard time differ by an hour.
The extra hour implies that now is standard time and December is DST. If it were the other way around then it would be an hour less rather than an hour more.

4. Originally Posted by felgall
The extra hour implies that now is standard time and December is DST. If it were the other way around then it would be an hour less rather than an hour more.
Run the code. Even if browsers are not consistent about which one is Standard and which one is Daylight, all of them give the same one extra hour difference: GMT+0100 vs. GMT+0200.

IE10
Sat Dec 21 06:00:00 UTC+0100 2013
Thu Aug 21 23:44:42 UTC+0200 2013

FF23.0.1
Date {Sat Dec 21 2013 06:00:00 GMT+0100 (GTB Daylight Time)}
Date {Thu Aug 21 2013 23:47:34 GMT+0200 (GTB Standard Time)}

Op15
Sat Dec 21 2013 06:00:00 GMT+0100 (GTB Standard Time)
Thu Aug 21 2013 23:49:17 GMT+0200 (GTB Daylight Time)

Ch29
Sat Dec 21 2013 06:00:00 GMT+0100 (GTB Standard Time)
Thu Aug 21 2013 23:50:33 GMT+0200 (GTB Daylight Time)

5. Originally Posted by myty
Even if browsers are not consistent about which one is Standard and which one is Daylight, all of them give the same one extra hour difference:
ALL browser will identify the same one as standard and the same one as daylight - which is which depends on the timezone/location the local computer is set to and has nothing to do with the browser.

There will be three possible results for that date comparison depending on where in the world the person running the code is located.
1. If their location is currently on standard time and will be on daylight time in December it will be an hour more than expected.
2. If their location is currently on daylight time and December is standard time then it will be an hour less than expected.
3. If their location does not use daylight time at all then it will not be out either way.

6. Originally Posted by felgall
ALL browser will identify the same one as standard and the same one as daylight - which is which depends on the timezone/location the local computer is set to and has nothing to do with the browser.
Again, just RUN the code, ANALYZE the results.
As you can see from the results I posted above, NOT ALL browser(s) will id the same one as Daylight. I'm not sure what your angle is arguing against the obvious...

7. Originally Posted by felgall
The extra hour implies that now is standard time and December is DST. If it were the other way around then it would be an hour less rather than an hour more.
Originally Posted by felgall
If I were to run that same code here in Australia then instead of all your results matching my number 2 point above it would instead match the number 1 point. Someone closer to the equator where they don't have daylight time it would not have the hour difference either way.
You are correct.
That's what I meant by "... or the other way around, depends where you're asking".

8. Not really, no.
In post#3, you quoted my first post, post#2, implying I was only accounting for one scenario: northern hemisphere. I wasn't.

date is GTB Daylight Time.
now is GTB Standard Time.
... or the other way around, depending on where you're asking.

Daylight and Standard time differ by an hour.
Hopes this clarifies things.

Regarding the FF bug, I thought it was a worthy mention, especially since you resorted to caps to enforce a slightly wrong point of view.

9. My post #3 was simply expanding on your post #2 to clarify that the way around that applied in the OP's location. I was not disagreeing with you as to that elsewhere it could be the other way around.

The only other discrepancies that have shown up in this thread is that Firefox is reporting things backwards as to which timezone is which and you got things bacvkwards in post #8 as to which browsers are misreporting your current timezone.

Apart from those discrepancies we are in agreement.