Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6545473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:35:23+00:00 2026-05-25T11:35:23+00:00

I’m using Keith Wood’s jQuery datepicker http://keith-wood.name/datepick.html to make a calendar that the user

  • 0

I’m using Keith Wood’s jQuery datepicker http://keith-wood.name/datepick.html to make a calendar that the user can use to switch between a range of dates or selecting individual dates. The site itself can be viewed at http://www.hasslers.org.

The calendar works well as is, but it has a problem with computing the cost of the range of days. The way the code works is it takes a string from the datepicker representing the two dates and breaks them into separate strings. From there, the string information is converted into seperate variables representing the day, month, and year.

The variables all show the proper values when I use an alert window to pop them up. I can select almost any beginning day and have the script work perfectly; however, when I select the current day or the day after the new date variable sets itself to October 1st. This only happens with days near the current day.

Enough of my rambling, here is the section of the code that seems to be the troublemaker:

    var dates_string = datepicker_data.toString();

    var dates = dates_string.split(',');

    var day1 = dates[0].slice(8, 10);
    var day2 = dates[1].slice(8, 10);

    var month1 = dates[0].slice(4, 7);
    var month2 = dates[1].slice(4, 7);

    switch(month1) {
        case "Jan":
            month1 = 0;
            break;
        case "Feb":
            month1 = 1;
            break;
        case "Mar":
            month1 = 2;
            break;
        case "Aprl":
            month1 = 3;
            break;
        case "May":
            month1 = 4;
            break;
        case "Jun":
            month1 = 5;
            break;
        case "Jul":
            month1 = 6;
            break;
        case "Aug":
            month1 = 7;
            break;
        case "Sep":
            month1 = 8;
            break;
        case "Oct":
            month1 = 9;
            break;
        case "Nov":
            month1 = 10;
            break;
        case "Dec":
            month1 = 11;
            break;
    }

    switch(month2) {
        case "Jan":
            month2 = 0;
            break;
        case "Feb":
            month2 = 1;
            break;
        case "Mar":
            month2 = 2;
            break;
        case "Aprl":
            month2 = 3;
            break;
        case "May":
            month2 = 4;
            break;
        case "Jun":
            month2 = 5;
            break;
        case "Jul":
            month2 = 6;
            break;
        case "Aug":
            month2 = 7;
            break;
        case "Sep":
            month2 = 8;
            break;
        case "Oct":
            month2 = 9;
            break;
        case "Nov":
            month2 = 10;
            break;
        case "Dec":
            month2 = 11;
            break;
    }

    var year1 = dates[0].slice(11, 15);
    var year2 = dates[1].slice(11, 15);

    var split_date1 = new Date();
    var split_date2 = new Date();

    split_date1.setDate(parseInt(day1));
    split_date2.setDate(parseInt(day2));

    split_date1.setMonth(month1);
    split_date2.setMonth(month2);

    split_date1.setYear(parseInt(year1));
    split_date2.setYear(parseInt(year2));

    // get number of days by dividing by 86400000 milliseconds (number in a day)
    number_of_days = ((split_date2 - split_date1) / 86400000) + 1;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:35:24+00:00Added an answer on May 25, 2026 at 11:35 am

    You’re using two digits for the day of the month:

    var day1 = dates[0].slice(8, 10);
    var day2 = dates[1].slice(8, 10);
    

    I don’t know what format your dates are in but if the eighth is represented as 08 then you’re in trouble. The parseInt function has a second argument that specifies the base of the number; if you don’t specify the radix then parseInt will have to guess and if you give it a number that begins with a zero, it will guess octal. The result is that parseInt('08') will result in zero because 8 is not a valid octal digit. You should always specify the radix when using parseInt.

    Today is conveniently the 8th so let us look what happens.

    var d = new Date();
    // Thu Sep 08 2011 20:12:43 GMT-0700 (PDT)
    d.setDate(parseInt('08'));
    d.toString();
    // "Wed Aug 31 2011 20:12:43 GMT-0700 (PDT)"
    

    And so we lose some time while attempting to set the date to the 8th and everything goes sideways after that.

    I’m not sure if this is your specific problem but it is a nasty problem that needs to be fixed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Does anyone know how can I replace this 2 symbol below from the string
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need to clean up various Word 'smart' characters in user input, including but
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.