Such is the way with programming.
Here's my take on it. Pull all your values into one long string:
$date_string = "{$_POST["week_day"]}, {$_POST["month"]} {$_POST["day"]}, {$_POST["year"]}";
Now, you have a string in the format "Saturday, March 20, 2004".
Now, use strtotime() to figure out whether it's a valid date:
if (($timestamp = strtotime($date_string)) === -1) { // Not a valid date; do some error reporting here } else { // It is a valid date, $timestamp is now a valid Unix // timestamp of $date_string; use it like below: echo date("m/d/Y", $timestamp); }
See also http://us4.php.net/strtotime
Chris Bruce wrote:
Hello all,
I was going to build a function to check whether a selected date exists, but thought that I would see if anyone has done this type of thing already which would indeed save me some time.
I have a form where the users select the day of the week, month, date and year from 4 pulldowns. (Saturday, March 20, 2004). I need to have a function that will check to see if that is indeed a real date.
Does this sound familiar to anyone?
Thanks a bunch :)
--
Chris Bruce [EMAIL PROTECTED]
Idextrus E-Business Architects http://www.idextrus.com 3282 Wilmar Cres. Mississauga, ON L5L4B2 CA 905.828.9189
**************************************************************** This e-mail and its contents are privileged, confidential and subject to copyright. If you are not the intended recipient, please delete this e-mail immediately. Any unauthorized use or disclosure of the information herein is prohibited.
-- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamsey
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php