Skip to content Skip to sidebar Skip to footer

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:

<scripttype="text/javascript">
$( "#datepicker" ).datepicker({        
    dateFormat: 'dd-mm-yy',
    maxDate: newDate(<?phpecho($maxDate[0]);?>,<?phpecho($maxDate[1]);?>,<?phpecho($maxDate[2]); ?>),
    minDate: newDate(<?phpecho($minDate[0]);?>,<?phpecho($minDate[1]);?>,<?phpecho($minDate[2]); ?>)
});
</script>

Post a Comment for "Uidatepicker - Mindate & Maxdate From Php Var"