PDA

View Full Version : Really strange Dynamic Countdown Script issue



4fit?
09-08-2008, 05:31 PM
1) Script Title: Dynamic Countdown Script

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex6/dhtmlcount.htm

3) Describe problem:
I am currently viewing this script at 1:18 EDT. In the days before Chrismas example, it says "107 Days 11 Hours 41 Minutes 17 Seconds". However, since it is already 1:18, it should actually say "107 Days 10 Hours 41 Minutes 17 Seconds".

But, if you change it to say 10/31/2008, the hours correct themselves. I was thinking that it might be something dealing with the 31 day months, like October. But, I changed it to 3/31/2009 and the hours worked correctly. They also worked correctly for 5/31/2009. However, when I change it to 11/4/2009, the hours are off by one. After doing a little testing, this seems to happen whenever the date desired is between 11/2 and 3/8.

What in the world could be causing this? I thought leap years may be the culprit, but that seems like it would put the script off by a whole day, not just an hour. I am really stumped on this one and need to come up with some kind of solution as quickly as possible. :confused:

Any help and/or guidance would be greatly appreciated!

ddadmin
09-08-2008, 11:13 PM
I think the problem is due to Day Light Savings Time, which actually means there is no issue with the script then (if my theory is correct). Right now since we are in DST, based on current Math, it would seem the script is off by +1 hours. However, this is only temporary until we leave DST, in which the script would then be correct. The Date function in JavaScript accounts for DST internally when doing calculations, projecting the final, correct time left to a certain date, even though at the moment, it may seem incorrect if you just did the math between the current and final date manually.

4fit?
09-09-2008, 12:05 PM
Ahaa! Ya know, that makes perfect sense. Thanks for the explanation! :D