Jquery Date picker Default Date

后端 未结 6 2057
忘了有多久
忘了有多久 2020-12-01 13:37

I am using a Jquery Datepicker in my project. The problem is that it is not loading the current date, but showing a date 1st January 2001 as default. Can you please let me k

相关标签:
6条回答
  • 2020-12-01 14:09

    $( ".selector" ).datepicker({ defaultDate: null });

    and return empty string from backend

    0 讨论(0)
  • 2020-12-01 14:14

    While the defaultDate does not set the widget. What is needed is something like:

    $(".datepicker").datepicker({
        showButtonPanel: true,
        numberOfMonths: 2
    
    });
    
    $(".datepicker[value='']").datepicker("setDate", "-0d"); 
    
    0 讨论(0)
  • 2020-12-01 14:19

    interesting, datepicker default date is current date as I found,

    but you can set date by

    $("#yourinput").datepicker( "setDate" , "7/11/2011" );
    

    don't forget to check you system date :)

    0 讨论(0)
  • 2020-12-01 14:23

    i suspect that your default date format is different than the scripts default settigns. test your script with the 'dateformat' option

    $( "#datepicker" ).datepicker({ 
        dateFormat: 'dd-mm-yy'
    });
    

    instead of dd-mm-yy, your desired format

    0 讨论(0)
  • 2020-12-01 14:29

    Use the defaultDate option

    $( ".selector" ).datepicker({ defaultDate: '01/01/01' });
    

    If you change your date format, make sure to change the input into defaultDate (e.g. '01-01-2001')

    0 讨论(0)
  • 2020-12-01 14:30

    Are u using this datepicker http://jqueryui.com/demos/datepicker/ ? if yes there are options to set the default Date.If you didn't change anything , by default it will show the current date.

    any way this will gives current date

    $( ".selector" ).datepicker({ defaultDate: new Date() });
    
    0 讨论(0)
提交回复
热议问题