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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:56:58+00:00 2026-05-22T00:56:58+00:00

I am trying to set the date to a specific one on page load

  • 0

I am trying to set the date to a specific one on page load so I’m trying this code:

    <script type="text/javascript">


    $(document).ready(function() { 

  var queryDate = new Date();
queryDate.setFullYear(2009,11,01);
$('#date').datepicker({defaultDate: queryDate});


$("input[type='submit']").click(function(e) {
            e.preventDefault();
            $.post("s.php", $("form").serializeArray(), function(message) {
                window.location="v.php" 
            });
        });
    });

</script>

//The form part where is displays the datepicker:

<form action="#" method="POST">
<div data-role="fieldcontain">
<label for="date">Date:</label>
<input type="date" name="date" id="date" value=""  />
<input type="submit" value="submit" />
 </div>     
</form>

The problem is that nothing’s changing … the default is still the current date :o/

Any ideas anyone please?

UPDATE: Tried this code:

var queryDate = new Date(2009,11,01);
$('#date').datepicker({defaultDate: queryDate});
$('#date').val(queryDate);

And the date is appearing in the input box but the calendar is not in the right month nor date … Moving foward but still not working.

  • 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-22T00:56:59+00:00Added an answer on May 22, 2026 at 12:56 am

    Umm what if you tried this

    new Date(year, month, day, hours, minutes, seconds, milliseconds)

    var queryDate = new Date();
    queryDate.setFullYear(2009,11,01);
    $('#date').datepicker({defaultDate: queryDate});
    

    Then the datepicker knows its a date object and how to handle it.


    EDIT
    Ok – all i did was copy the code exactly as you got it here several posts the same suggestion- and the code you edited. Added tags- inlcuded jquery and jquery ui..
    I see no problem- the defuatl date is 2009.

    </head>
    <script src="jquery.min.js" type="text/javascript"></script>
    <script src="jquery-ui.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    $(document).ready(function() { 
    var queryDate = new Date();
    queryDate.setFullYear(2009,11,01);
    $('#date').datepicker({defaultDate: queryDate});
    
    $("input[type='submit']").click(function(e) {
            e.preventDefault();
            $.post("s.php", $("form").serializeArray(), function(message) {
                window.location="v.php" 
            });
          });
       });
      </script>
    
    </head>
    
    <body>
    //The form part where is displays the datepicker:
    
    <form action="#" method="POST">
    <div data-role="fieldcontain">
    <label for="date">Date:</label>
    <input type="date" name="date" id="date" value=""  />
    <input type="submit" value="submit" />
    
    </div>     
    </form>
    
    </body>
    

    Result (no styles sheet attached)
    enter image description here

    Working example- tell me what is wrong

    http://jsfiddle.net/ppumkin/nptgn/

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

Sidebar

Related Questions

I am trying to set a javascript date so that it can be submitted
I'm trying to get the code of a html document in specific tags. My
When am trying to set default date and default sysdate am getting following errors:
I'm trying to set up a date of birth helper in my Rails app
I am trying to set my columns default date time to system datetime. It
Im trying set the single table inheritance model type in a form. So i
Trying to set it so if a certain condition is met then one of
I'm trying to set the date of a UIDatePicker but I the month is
I am trying to set the date to todays date in the rad date
I am trying to set the date format of the date picker element, 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.