Wednesday, April 7, 2010

date 31 for setDate javascript

Date.setDate(day) day:1-31
When use setDate, setMonth and setYear in javascript.
Must be in order setYear, setMonth, setDate
 otherwise setDate(31) will create wrong date

actually not like this, always do a hack setDate first with hard code value is one

echo "dspStartDate.setDate(1);\n";
echo "dspStartDate.setFullYear(" . date("Y", $startstamp) . ");\n";
echo "dspStartDate.setMonth(" . (date("m", $startstamp) - 1) . ");\n";

//down here the the date that you would like to set

echo "dspStartDate.setDate(" . date("d", $startstamp) . ");\n";