UIDatePicker - minDate & maxDate from php Var

五迷三道 提交于 2019-12-02 07:33:29

Your array data is probably being placed into the javascript Date() constructor in the wrong order. Assuming your date strings are in the format YYYY-MM-DD and you print_r() your $maxdate array you should see something like this:

Array
(
    [0] => 2011
    [1] => 0
    [2] => 01
)

Notice that this array's indices are in the order 0=>year, 1=>month, 2=>day. So you need to modify your Date() constructors to align those values with the constructors input parameters like this:

<script type="text/javascript">
$( "#datepicker" ).datepicker({        
    dateFormat: 'dd-mm-yy',
    maxDate: new Date(<?php echo($maxDate[0]);?>,<?php echo($maxDate[1]);?>,<?php echo($maxDate[2]); ?>),
    minDate: new Date(<?php echo($minDate[0]);?>,<?php echo($minDate[1]);?>,<?php echo($minDate[2]); ?>)
});
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!