How to compare the date parts of two Zend_Date objects?

不想你离开。 提交于 2019-11-29 11:03:32
$date1 = new Zend_Date('2011-11-14 10:45:00');
$date2 = new Zend_Date('2011-11-14 19:15:00');
if ($date1->compareDay($date2) === 0) {
    echo 'same day';
}

Also see the chapter on Comparing Dates with Zend Date

On a sidenote, I strongly encourage you to verify if you have the need for Zend_Date. Do not use it just because it is part of ZF. Most of what Zend_Date does can be achieved faster and more comfortably with native DateTime as well:

$date1 = new DateTime('2011-11-14 10:45:00');
$date2 = new DateTime('2011-11-14 19:15:00');
if ($date1->diff($date2)->days === 0) {
    echo 'same day';
}

EDIT after comments
If you want to compare whether it's the same date just do

$date1->compareDate($date2)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!