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?

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!");

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.

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)

Some more readup: http://stackoverflow.com/questions/11887934/check-if-daylight-saving-time-is-in-effect-and-if-it-is-for-how-many-hours.

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.

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…

From the results you posted above ALL browsers show now to be standard time, December to be Daylight time based on the timezones - why Firefox has the narrations on the end backwards isn’t going to make any difference to the time calcularions or which timezones that the calculation works with. I didn’t even realise that the browsers were displaying such things on the end as I never display the dates like that.

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.

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)}

indicates that there is a bug in that version of Firefox that has reversed the narrations on the end. UTC+1 is GTB standard time and UTC+2 is GTB Daylight time irrespective of which browser you are using.

You should really take a closer look at the code and at the results.
I’m in northern hemisphere, so from the results I posted all but FF show Daylight for me for “now”, not Standard. It’s the reason I said that “even if browsers are not consistent”.

Date is an object with many properties and methods. There isn’t a single way to display dates, but that’s the default display.

I don’t understand why aren’t you just running the code at your end and analyze the results? I don’t believe using the console is so difficult. Anyway, since you’re on southern hemisphere, “now” for you is Standard.

You are correct.
That’s what I meant by “… or the other way around, depends where you’re asking”.

I have - everything that I have said is based on those results. The only thing I hadn’t done before my prior posts was to display the results using the format where the Firefox bug causes the Standard/Daylight references to display backwards. You seem to be concentrating so much on that one bug that you are completely overlooking how dates and times work outside the computer and what the computer should be (and is except for that bug) doing to match.

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.

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.