Thanks dude, that looks way nicer. I did however get it working by changing
the casting (tried to post my correction, but hit the wrong button), the
corrected, and after Lynch's enlightening me on mktime´s behaviour even butt
uglier code can be found below. (Change in arguments is solely due to a
redesign of the form).
On a mere philosophical level I'd like to know how the original code could
work on IE5, it's also got a dead obvious bug in the zeroPadDate() function
(didn't set $mstr or $dstr when month>=10 or day>=10). And no, it wasn't
due to using different arguments to the script on the different browsers...
Anyway, thanks! //Claes
/*
Function getDates(from, to) takes strings containing dates in the form
"YYYY-MM-DD"
and returns an array containing the dates between "from" and "to"
inclusive
*/
function getDates($f_year, $f_month, $f_date, $t_year, $t_month, $t_date) {
$year=(int) $f_year;
$month=(int) $f_month;
$date=(int) $f_date;
$to=zeroPadDate((int) $t_year, (int) $t_month,(int) $t_date);
$datearray[0]=zeroPadDate($year, $month, $date);
$current=$datearray[0];
while($current!=$to) {
$date=$date+1;
if(checkdate($month, $date, $year)) {
$current=zeroPadDate($year, $month, $date);
$datearray[]=$current;
} else {
$month=$month+1;
$date=1;
if (checkdate($month, $date, $year)) {
$current=zeroPadDate($year, $month, $date);
$datearray[]=$current;
} else {
$year=$year+1;
$month=1;
$current=zeroPadDate($year, $month, $date);
$datearray[]=$current;
}
}
}
return $datearray;
}
/* Accessory function to getDates above. */
function zeroPadDate($year, $month, $date) {
if ($month<10) {
$mstr="0$month";
} else {
$mstr=$month;
}
if ($date<10) {
$dstr="0$date";
} else {
$dstr=$date;
}
return "$year-$mstr-$dstr";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]