The format string "Y" is not the real year.
ISO defines it as calendar year (or year of the week) which is calculated
differently.
Use "y" when you need the real year.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Jace Ju" <jaceju@gmail.com>
To: <fw-core@lists.zend.com>
Sent: Friday, November 14, 2008 10:33 AM
Subject: [fw-core] Problem of Zend_Date::addDay
> Hi All:
>
> I found a problem of Zend_Date:
>
> [code]
> <?php
> require_once 'Zend/Date.php';
>
> date_default_timezone_set('Asia/Taipei');
>
> $today = new Zend_Date();
> $today->setDate('2008-11-21');
>
> $expireDateTime = clone $today;
> $expireDateTime->addDay(40);
>
> echo $expireDateTime->toString('YYYY-MM-dd');
>
> // expect : 2008-12-31
> // actual : 2009-12-31
> [/code]
>
> When I used addDay method to add $today to year 2001~2008, month 12, and
> day
> 29~31, the year would be wrong.
>
> For Example:
>
> 2008-11-09 + 50(days) = 2009-12-29 (wrong)
> 2008-11-01 + 50(days) = 2008-12-21 (right)
> 2007-11-21 + 40(days) = 2008-12-31 (wrong)
> 2007-11-11 + 50(days) = 2008-12-31 (wrong)
> 2009-11-11 + 50(days) = 2009-12-31 (right)
> 2009-11-21 + 40(days) = 2008-12-31 (right)
> 2000-11-21 + 40(days) = 2000-12-31 (right)
> 2001-11-21 + 40(days) = 2002-12-31 (wrong)
> ...
>
> Is this a bug? Or missing out something?
>
> Please forget my poor english.
>
>
>
> Jace Ju
>
没有评论:
发表评论