function question

From: Date: Thu, 01 May 2003 13:02:04 +0000
Subject: function question
Groups: php.general 
Request: Send a blank email to php-general+get-145941@lists.php.net to get a copy of this message
Hi, I am using a function mofied from an earlier post to check whether a given date is valid and does not occur in the past, however when i try to use the function with: if(futureDate($_POST[booking_date]) == 'weekend'){ echo 'date is a weekend' } and the function is returning zero, it still enters the loop and prints 'date is a weekend' I would be grateful for your help as this doesn't make sense to me! Date checking function: function futureDate($timestamp){ $error = 0; $flag = 0; $t = split("/",$timestamp); if (count($t)!=3) $t = split("-",$timestamp); if (count($t)!=3) $t = split(" ",$timestamp); if (count($t)!=3){ $error = 'invalid'; $flag = 1; } if (!is_numeric($t[0])){ $error = 'invalid'; $flag = 1; } if (!is_numeric($t[1])){ $error = 'invalid'; $flag = 1; } if (!is_numeric($t[2])){ $error = 'invalid'; $flag = 1; } if ($t[0]<1902 || $t[0]>2037){ $error = 'invalid'; $flag = 1; } if (date("D", mktime(0, 0, 0, $t[1], $t[2], $t[0])) == 'Sat'){ $error = 'weekend'; $flag = 1; } if (date("D", mktime(0, 0, 0, $t[1], $t[2], $t[0])) == 'Sun'){ $error = 'weekend'; $flag = 1; } $timeStamp = mktime(0,0,0, $t[1], $t[2], $t[0]); if(!($timeStamp >= time()) && $flag == 0){ $error = 'past'; } return $error; } ?>

« previous php.general (#145941) next »