UIDatePicker - MinDate & MaxDate From Php Var
I have some php which queries a database to get some dates:
Solution 1:
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>
Post a Comment for "UIDatePicker - MinDate & MaxDate From Php Var"