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 = $da
I've extended Zend_Date for my own convenience functions. My solution is similar to Nisanth's, with some key differences:
round() instead of ceil()1 to the resultExample code:
class My_Date extends Zend_Date
{
public static function now($locale = null)
{
return new My_Date(time(), self::TIMESTAMP, $locale);
}
/**
* set to the first second of current day
*/
public function setDayStart()
{
return $this->setHour(0)->setMinute(0)->setSecond(0);
}
/**
* get the first second of current day
*/
public function getDayStart()
{
$clone = clone $this;
return $clone->setDayStart();
}
/**
* get count of days between dates, ignores time values
*/
public function getDaysBetween($date)
{
// 86400 seconds/day = 24 hours/day * 60 minutes/hour * 60 seconds/minute
// rounding takes care of time changes
return round($date->getDayStart()->sub(
$this->getDayStart()
)->toValue() / 86400);
}
}