0

I have two dates given as Zend_Date(). I must check the following:

  1. if theese dates are in the same month day (for example: second day of the month, year does not matter),
  2. if dates are from exactly the same day(for example 2 december 2012);
doydoy44
  • 5,720
  • 4
  • 29
  • 45
masteryoda
  • 272
  • 2
  • 20

1 Answers1

0

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.

Altaf Hussain
  • 5,166
  • 4
  • 30
  • 47
Sam
  • 1