Send the function a date in an array like $arr["year"], $arr["month"] and $arr["day"]. This function does not return an error or give you a hint that the date you picked was invalid, it just returns a timestamp that you can use in the date function.
$date = "";if (sizeof($_POST) > 0) {$date = '<h1>'.valiDate($_POST).'</h1>';}function valiDate($arr) {$year = intval(substr($arr["year"], 0, 4));$month = intval(substr($arr["month"], 0, 2));$day = intval(substr($arr["day"], 0, 2));// not in form but needs to be set, this is for clarity.$n_hour = 8;$n_minute = 0;$n_second = 0;$timestamp = mktime($n_hour, $n_minute, $n_second, $month, $day, $year);$date = date($arr["dateformat"], $timestamp);return $date;}