Calendar with select box

I have an events calendar, which stores events in a mysql database by timestamps. (1226469600 = 12 nov 2008)

Now I need a second calendar which checks the database for events when a user picks a date through 3 select boxes. 3 select boxes with day, month and year. When the select boxes are set, a result will show at the bottom. (no datepickers, I need 3 select boxes!)
Is there a possibility to return an error when the user picks a date that doesn't exist?
How do I check the timestamp from these 3 boxes and return the result at the bottom?

Any ideas?
LVL 2
Hori76Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jausionsCommented:
Use the PHP checkdate() function [1] to validate a date.

[1] http://www.php.net/manual/en/function.checkdate.php
0
Roger BaklundCommented:
Use mktime() to calculate the timestamp, and then use date('Y-m-d') to check that the date was valid.

mktime() will accept invalid dates and transform it to a valid date. That's why you must use date() to check if the calculated date is the same as provided by the user. Remember to use two digits in the select dropdowns, i.e. 01, 02, 03 and so on.
<?php
 
$d = $_POST['day'];
$m = $_POST['month'];
$Y = $_POST['year'];
 
$date = mktime(0,0,0,$m,$d,$Y);
if(date('Y-m-d',$date)!="$Y-$m-$d") 
  echo 'Invalid date!';
 
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ovi_mihaiCommented:
i supose you want a javascript solution..
you can put a javascript on the submit button or on the select boxes

something like

var date1 = document.form.select1.value + "/" + ocument.form.select2.value + "/" +ocument.form.select3.value ;
var ret = isDate(date1, "d/m/Y"); //for 20/02/2008

rename date.js.txt in date.js
date.js.txt
0
Hori76Author Commented:
Thanks! This is exactly what i needed!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.