.datepicker('setdate') issues, in jQuery

后端 未结 6 894
轻奢々
轻奢々 2020-12-06 04:11

I have a function that executes a query to get some data based on a certain date range which is selected using .datepicker(). I am trying to set the datepicker\'s that are

6条回答
  •  无人及你
    2020-12-06 04:33

    If you would like to support really old browsers you should parse the date string, since using the ISO8601 date format with the Date constructor is not supported pre IE9:

    var queryDate = '2009-11-01',
        dateParts = queryDate.match(/(\d+)/g)
        realDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);  
                                        // months are 0-based!
    // For >= IE9
    var realDate = new Date('2009-11-01');  
    
    $('#datePicker').datepicker({ dateFormat: 'yy-mm-dd' }); // format to show
    $('#datePicker').datepicker('setDate', realDate);
    

    Check the above example here.

提交回复
热议问题