Is there any reason you can't store time() instead? If you need the d/m/y out of it later, you could use date() then.
Otherwise, the simplest way would be to use:
PHP Code:
if (strtotime("$itemE_month/$itemE_day/$itemE_year $itemE_hour:$itemE_minute $itemE_ampm") > time()) { echo "yup"; }
It's more intensive than checking the logic but it's far simpler.
PHP Code:
if ($item_year > $year) { echo "yes"; }
if ($item_year == $year) {
if ($item_month > $month) { echo "yes"; }
elseif ($item_month == $month) {
if ($item_day > $day) { echo "yes"; }
elseif ($item_day == $day) {
if ($item_hour > $hour) { echo "yes"; }
elseif ($item_hour == $hour) {
if ($item_minute > $minute) { echo "yes"; }
}
}
}
}
Another way would be:
PHP Code:
$old = array(
$item_year,
$item_month,
$item_day,
$item_hour,
$item_minute
);
$new = array(
$year,
$month,
$day,
$hour,
$minute
);
function compare_dates($old, $new) {
for ($i=0;$i<4;$i++){
if ($old[$i] < $new[$i]) { return "no"; }
if ($old[$i] > $new[$i]) { return "yes"; }
}
return "equal";
}
echo compare_dates($old, $new);