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?
Who is Participating?
Roger BaklundConnect With a Mentor Commented:
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.
$d = $_POST['day'];
$m = $_POST['month'];
$Y = $_POST['year'];
$date = mktime(0,0,0,$m,$d,$Y);
  echo 'Invalid date!';

Open in new window

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

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
Hori76Author Commented:
Thanks! This is exactly what i needed!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.