MoopanMec
MoopanMec

Reputation: 47

Zend _date difference php error

I used the below code for finding the difference in days for two dates :

   1 $startDate = new Zend_Date('2010-02-28', 'YYYY-MM-dd');
   2 $lastDate  = new Zend_Date('2010-03-01', 'YYYY-MM-dd');
   3 $diff = $lastDate->sub($startDate)->toValue();
   4 $days = ceil($diff/60/60/24) +1;

The 3rd line in php shows me an error :

Expected an operand but found Refs:Zend Date -- day difference

Upvotes: 0

Views: 40

Answers (1)

user3773761
user3773761

Reputation:

Use in 3rd line

$diff = $lastDate->sub($startDate)->toString(Zend_Date::DAY);

that solve your problem.

Upvotes: 1

Related Questions