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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:49:34+00:00 2026-06-02T10:49:34+00:00

I have 2 datepickers in jquery where I add a single day to the

  • 0

I have 2 datepickers in jquery where I add a single day to the date of one picker and assign it to another date picker like so:

 /*assign date pickers*/
        $("#MainContent_txtActualShipDate").datepicker({
            dateFormat: 'mm/dd-yyyy',
            changeMonth: true,
            changeYear: true,
            showOtherMonths: true,
            selectOtherMonths: true
        });

        $("#MainContent_txtExpectedShipDate").datepicker({
            changeMonth: true,
            changeYear: true,
            showOtherMonths: true,
            selectOtherMonths: true,
            onSelect: function (selectedDate) {
                var date = $(this).datepicker('getDate');

                if (date) {
                    date.setDate(date.getDate() + 1);
                    $("#MainContent_txtActualShipDate").val(date);
                }

            }
        });

Notice the onSelect function adds a single date and assigns it to #MainContent_txtActualShipDate but the value it gets is “TUE APR 24 2012 00:00:00”.
I want it to be simply ’04/24/2012′ so mm/dd/yyyy. I read the jquery ui docs and looked up some examples on stackoverflow but none of them worked. Is there anyone that can look at this code and edit to get the format I want?

Edit

Here is what I change it to:

        $("#MainContent_txtExpectedShipDate").datepicker({
            dateFormat: 'mm/dd-yyyy',
            changeMonth: true,
            changeYear: true,
            showOtherMonths: true,
            selectOtherMonths: true,
            onSelect: function (selectedDate) {
                var date = $(this).datepicker('getDate');

                if (date) {
                    date.setDate(date.getDate() + 1);
                    var formattedDate = $.datepicker.formatDate('mm/dd-yyyy', date);
                    $("#MainContent_txtActualShipDate").val(formattedDate); 

//                    $("#MainContent_txtActualShipDate").val(date);
                }

            }
        });

But it shows the year twice 04/12/20122012.

Answer

Here is what worked for others in the future:

/*assign date pickers*/
        $("#MainContent_txtActualShipDate").datepicker({
            dateFormat: 'mm/dd/yy',
            changeMonth: true,
            changeYear: true,
            showOtherMonths: true,
            selectOtherMonths: true
        });

        $("#MainContent_txtExpectedShipDate").datepicker({
            dateFormat: 'mm/dd/yy',
            changeMonth: true,
            changeYear: true,
            showOtherMonths: true,
            selectOtherMonths: true,
            onSelect: function (selectedDate) {
                var date = $(this).datepicker('getDate');

                if (date) {
                    date.setDate(date.getDate() + 1);
                    var formattedDate = $.datepicker.formatDate('mm/dd/yy', date);
                    $("#MainContent_txtActualShipDate").val(formattedDate); 
                }

            }
        });
        /*end assign date pickers*/

Thanks

  • 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-02T10:49:35+00:00Added an answer on June 2, 2026 at 10:49 am

    Use the formatDate() function:

    var formattedDate = $.datepicker.formatDate('mm/dd/yy', date);
    $("#MainContent_txtActualShipDate").val(formattedDate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two jquery ui datepickers in my page and I would like to
I have a jquery datepicker which is renders the current date by default as
I'm using the jQuery datepicker where I have two textboxes (start date / end
I am using the datepicker from jquery ui and I'd like add a script
I have this program and i want to add a jquery datepicker on it,
I have added the JQuery Datepicker control to one of my ASP.Net pages. The
Basically I'm using datepicker from jQuery to have my client pick a date. I
I have a simple View and I wish to add a JQuery DatePicker JavaScript
I have a Javascript function which gets a date from a jQuery datepicker. Now
I have a jQuery UI DatePicker calendar that alerts when a date is clicked

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.