我有两个日期作为Zend_Date()
. 我必须检查以下内容:
- 如果这些日期在同一个月的某一天(例如:每月的第二天,年份无关紧要),
- 如果日期来自同一天(例如 2012 年 12 月 2 日);
我有两个日期作为Zend_Date()
. 我必须检查以下内容:
To check the dates are the exact same day, you can check each individual part separately.
Zend_Date('your-date-here',Zend_Date::DAY);
This returns a date object that specifically gives you the day for the 'your-date-here' and it accepts a variety of formats; for example, I use php's date function as:
$myDate = date('Y-m-d-H-i-s');
$dateDayObject = Zend_Date($myDate, Zend_Date::DAY);
and now $dateDayObject will have the value of the 'd' in it.
You can use DAY, WEEK, YEAR... there are many constant all defined here:
http://framework.zend.com/manual/1.12/en/zend.date.constants.html
Finally, to test if they are in the same day of the month, you can use a combination of loops and if statement and the same method as above to write your own function to check the day within the month or there may be a defined constant for it. Good luck.