简体   繁体   中英

Problems with JqueryUI Datepicker Date Object

I have from server side the date like follows

 endDate : Mon Nov 07 00:00:00 CET 2011 (Java.util.Date)
 startDate : Fri Feb 04 00:00:00 CET 2011 (Java.util.Date)

Now i have two jquery UI datepicker

I want to restrict the two datepickers so that user can select dates only from the above dates.

I saw like u can set the minDate and maxDate for a date picker.

I did some like follows in :

$("#startDatePicker").datepicker({
minDate: $.datepicker.formatDate( 'dd.mm.yy',new Date(startDate.getTime())),
maxDate: $.datepicker.formatDate( 'dd.mm.yy',new Date(endDate.getTime())),
...

$("#endDatePicker").datepicker({
minDate: $.datepicker.formatDate( 'dd.mm.yy',new Date(startDate.getTime())),
maxDate: $.datepicker.formatDate( 'dd.mm.yy',new Date(endDate.getTime())),
...

But something is wrong. In the start date picker he is showing 2020.? and end datepicker he has disabled everything in the datepicker. I don't understand what is wrong here..?

Add: jquery-dateFormat jQuery plugin.

Code

 var minDate = $.format.date(startDate, "dd/MM/yyyy");

 $("#startDatePicker").datepicker({
    minDate: minDate
    ...

Test sample:

 <script type="test/javascript">
       alert($.format.date("Wed Jan 13 10:43:41 CET 2010", "dd/MM/yyyy"));
 </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM