BUG: The countdown time calculates an erroneous amount of days

Author
Topic
#2254

The attached image is the result of your code sample running in a Chrome browser window.

It calculates the number of days between 01/03/2015 and 04/09/2015 as 215 when its only 187.

For my purposes, that’s a little too much margin of error.

Viewing 3 replies - 1 through 3 (of 3 total)
Author
Replies
  • #2256

    Hi,

    This is due to the way JavaScript Date object defines month, it is already discussed. In JavaScript months counting starts from 0 not 1, so it is from 0 to 11 not 1 to 12.

    Regards,
    Milan

  • #2257

    Hmm. OK, I guess that makes sense. But it still doesn’t explain why your demo is showing the wrong number of days.

  • #2258

    Demo is not wrong, There are 215 (or so) days until October 4 (or month 9 in JS). Plugin uses JavaScript functions to get difference between two dates, it is not doing any calculations on it’s own.

    And, date title should be October 3 (days in JS object Date are from 1 to 31). Months start from 0, days from 1, what logic JavaScript creators used here we will never know :).

    Milan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘BUG: The countdown time calculates an erroneous amount of days’ is closed to new replies.