There is no good way to do this with DateTime objects. So what you have to do, let's say, are not very nice things.
$nDate1 = clone $date1;
$nDate2 = clone $date2;
$utc = new DateTimeZone('UTC');
$nDate1->setTimezone($utc);
$nDate2->setTimezone($utc);
$nDate1->setTime(0, 0, 0);
$nDate2->setTime(0, 0, 0);
if ($nDate1 == $nDate2) {
}
This will work, but, as I said, this is not nice.
On the other hand, recent experience tells me that it is always better that both dates are in the same time zone, so I added a code for this just in case.
source
share