note 91942 modified in function.date-diff by danbrown
| From: | danbrown@php.net | Date: | Thu, 02 Jul 2009 13:15:20 +0000 |
| Subject: | note 91942 modified in function.date-diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157820@lists.php.net to get a copy of this message | ||
If you simply want to compare two dates, using conditional operators works too:
<?php
$start = new DateTime('08-06-1995 Europe/Copenhagen'); // DD-MM-YYYY
$end = new DateTime('22-11-1968 Europe/Amsterdam');
if ($start < $end) {
echo "Correct order";
} else {
echo "Incorrect order, end date is before the starting date";
}
?>
--was--
If you simply want to compare two dates, using conditional operators works too:
<?php
$start = new DateTime('08-06-1995 Europe/Copenhagen'); // DD-MM-YYYY
$end = new DateTime('22-11-1968 Europe/Amsterdam');
if ($start < $end) {
echo "Correct order";
} else {
echo "Incorrect order, end date is before the starting date";
}
http://php.net/manual/en/function.date-diff.php