zend-date

How print all the weeks in an year (or first monday of year)

随声附和 提交于 2019-12-02 02:58:15
How print all the weeks which start with monday and end with sunday.. like below ..using Zend_date 1 04-Jan-2010-10-Jan-2010 2 11-Jan-2010-17-Jan-2010 3 18-Jan-2010-24-Jan-2010 Start by finding the first monday, then you can just add 1 week until the year increments. <?php define('NL', "\n"); $year = 2010; $firstDayOfYear = mktime(0, 0, 0, 1, 1, $year); $nextMonday = strtotime('monday', $firstDayOfYear); $nextSunday = strtotime('sunday', $nextMonday); while (date('Y', $nextMonday) == $year) { echo date('c', $nextMonday), '-', date('c', $nextSunday), NL; $nextMonday = strtotime('+1 week',

How to compare the date parts of two Zend_Date objects?

不想你离开。 提交于 2019-11-29 11:03:32
I'd like to check if to Zend_Date datetimes are on the same day. How can I do that? $date1 = new Zend_Date('2011-11-14 10:45:00'); $date2 = new Zend_Date('2011-11-14 19:15:00'); $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

How to compare the date parts of two Zend_Date objects?

核能气质少年 提交于 2019-11-28 04:08:05
问题 I'd like to check if to Zend_Date datetimes are on the same day. How can I do that? $date1 = new Zend_Date('2011-11-14 10:45:00'); $date2 = new Zend_Date('2011-11-14 19:15:00'); 回答1: $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

Zend Date — day difference

烂漫一生 提交于 2019-11-28 00:10:39
问题 I have the below line of codes $day1 = new Zend_Date('2010-03-01', 'YYYY-mm-dd'); $day2 = new Zend_Date('2010-03-05', 'YYYY-mm-dd'); $dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1->getDate()->get(Zend_Date::TIMESTAMP); $days = floor((($dateDiff / 60) / 60) / 24); return $days; this will return 4 But if gave $day1 = new Zend_Date('2010-02-28', 'YYYY-mm-dd'); $day2 = new Zend_Date('2010-03-01', 'YYYY-mm-dd'); $dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1-