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 8324183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:58:07+00:00 2026-06-08T23:58:07+00:00

EDIT: I just made a jsfiddle to demonstrate the problem here: http://jsfiddle.net/GvjRd/3/ I have

  • 0

EDIT: I just made a jsfiddle to demonstrate the problem here: http://jsfiddle.net/GvjRd/3/

I have a web tool that uses the JQuery UI datepicker. It has been working smoothly for weeks, but then all of a sudden it stopped working today. No matter what day/month/year I pick on the calendar, when I select a day and call alert(currentTime.getMonth()); it returns ‘7’. It returns the day/year just fine.

I proceeded to test just the datepicker on its own, making a very simple page:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <link type="text/css" href="ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
    <link rel="stylesheet" href="demos.css">
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery-ui-1.8.21.custom.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#datepicker").datepicker({
                onSelect : function(dateText, inst) {
                    var currentTime = new Date();
                    currentTime.setDate($("#datepicker").datepicker("getDate").getDate());
                    alert(currentTime.getMonth());
                }
            });
        });
    </script>

</head>
<body>
            Date:
            <input type="text" id="datepicker">
</body>

Even on this page, no matter what day/month/year combination I choose, the alert says ‘7’. Anyone else having this problem?

  • 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-06-08T23:58:09+00:00Added an answer on June 8, 2026 at 11:58 pm

    Months in JavaScript are zero based so 7 = the 8th month, or August.

    In your example, you’re setting the currentTime to today and then only changing the day of that date object to the date picked on the calendar, leaving the month and year unchanged. Therefore, currentTime.getMonth() will always show the month that the running the script in, not the date picked from the calendar. To do that, use currentTime.setMonth($("#datepicker").datepicker("getDate").getMonth());

    jsFiddle example

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

Sidebar

Related Questions

I made the following jsfiddle at http://jsfiddle.net/hxsy6/ The issue I have is that if
EDIT #2: Made a JS Fiddle... http://jsfiddle.net/N2p6G/ (I hardcoded some stuff that I'm certain
EDIT 2: I have just realised that my HTML is only displaying the artist
I have just made a step back from ASP .NET MVC application and moved
EDIT: Just to make things clear, this problem was caused by a typo in
Edit: just to be clearer on what I am looking to do. I have
EDIT I've just started skimming Codd's famous 1970 paper that started it all, that
I have to edit my question just to make it clear. What I need
Edit For simplicity: I just want to make the most basic possible cursor that
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls

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.