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

  • SEARCH
  • Home
  • 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 8136159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:40:16+00:00 2026-06-06T10:40:16+00:00

Good morning gang. I have a jQuery Datepicker object that is prepoulated using a

  • 0

Good morning gang.

I have a jQuery Datepicker object that is prepoulated using a javscript Date object, and I have getMonth() returning 50 as the month, instead of 5. This was previously working as recent as 4/27/2012.

Here’s the code:

$(document).ready(function(){

$('#datepicker1').attr('readonly', 'readonly');

var press_date = new Date(); //This is the Date object that you're getting from external source

$('#datepicker1').val(press_date.getFullYear()+'-'
                     +press_date.getMonth()+1+'-'
                     +press_date.getDate());

$('#datepicker1').datepicker({
                     showAnim:'slide',showOn: 'button',
                     dateFormat : 'yy-mm-dd',
                     buttonImage: 'images/calendar.jpg',
                     buttonImageOnly: true,onSelect: function(dateText, inst) {} 
                    });
$('#datepicker').attr('readonly', 'readonly');

$('#datepicker').datepicker({
                     showAnim:'slide',showOn: 'button',
                     dateFormat : 'yy-mm-dd',
                     buttonImage: 'images/calendar.jpg',
                     buttonImageOnly: true,onSelect: function(dateText, inst) {} 
                    });
});

My guess is that this is a simple issue to resolve, but I haven’t seen anything around the web to explain it.

  • 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-06T10:40:18+00:00Added an answer on June 6, 2026 at 10:40 am

    The issue is the x.getMonth()+1 in your expression. Since you are concatenating strings the parser is getting confused. You can surround the x.getMonth()+1 in parenthesis or just move that calculation outside of the string concatenation:

    For example, surround it with parenthesis:

    x.getFullYear()+'-'+(x.getMonth()+1)+'-'+x.getDate()

    UPDATE: To get the month value zero padded I would definitively move the calculation to its own line to make it clear:

    month = x.getMonth() + 1; 
    monthString = month < 9 ? '0' + month : month; 
    dbDate = x.getFullYear() + '-' + monthString + '-' + x.getDate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning. I have a modal JQuery dialog that on Open calls and loads
Good morning, I have problem with using MasterPage and jQuery. I using jQuery UI
Good Morning, I'm using Reporting Services 2005 to produce a one-time report that will
Good Morning, I have created an ASP.NET 3.5 webform that allows users to search
Good morning! I'm programming a managment aplication that shows a task list using WPF
Good Morning, I have a SharePoint site that I've been trying to fix up
Good morning folks, I'm just that beginner in json, I have a formated data
Good morning, I am working on a C# winform application that is using validation
Good Morning All, I have an Objective C question that is coming from JavaScript.
Good morning, I have a .Net 2.0 runtime DLL that I am trying to

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.