+1 : I have the same problem with the age calculation
On Tue, Apr 7, 2009 at 7:24 PM, Daryl Handley <[email protected]>wrote: > milesap wrote: > >> Hello, >> >> I'm fairly new to Zend Framework, so forgive me if this is a really easy >> question. I have been looking everywhere for a solution. I am trying to >> get >> the difference between the current date and a persons birthday to see how >> old they are. >> >> $date = new Zend_Date(); >> $date->sub('April 3, 1980'); >> >> print $date->toString('Y'); >> >> The following prints 28, however the correct age would be 29, as the >> persons >> birthday was a few days ago. Does it not take the month and day into >> account >> when it subs the date? Or a better question would be what am I doing >> wrong? >> >> I have set my default timezone correctly. >> >> > I'm no Zend_Date expert, but I've been looking at this for a bit mostly > because I am interested in how Zend_Date works. The behaviour of ->sub seems > a bit erratic. I would expect the following 2 code fragments to output the > same thing. > > $date = new Zend_Date('April 7, 2009'); > $date->sub('April 3, 1980'); > print $date->toString() . "\n"; > $date = new Zend_Date('April 7, 2009'); > $date->sub(new Zend_Date('April 3, 1980')); > print $date->toString() . "\n"; > > but they don't. The output is > > Dec 6, 0028 3:00:00 PM > Jan 4, 1999 3:00:00 PM > > I also experiment with 'y' vs 'Y' as suggested by Thomas and still got 28. > Gotta go do some other stuff, may take a look again later. > > Daryl > > > > -- Thomas VEQUAUD http://thomas.vequaud.free.fr/ Expert EPITECH en Ingénierie Informatique Tél : +33(0)6.50.39.28.10 Fax: +33(0)9.58.46.10.07
