Hello everybody,

I began yesterday my experiences for the Zend_Date class and I encountered
an not-understood behavior.

Fxc_Date_Public is a class inheriting from Zend_Date. It doesn't override
the constructor nor the getDate() method, nor the get() method.

In fact, I declared a Fxc_Date_Public object, representing yesterday by:

$today = new Fxc_Date_Public();

Next, I wanted to clone this one in one of its methods, by using the
getDate() method :

...
$candidate = $this -> getDate();
...

The return value ($candidate) should be a new date formatted with
Zend_Date::DATE_MEDIUM (as it is used in the getDate() method). Moreover, in
the documentation, we could see :

Zend_Date::DATE_MEDIUM | Normal date (string, localized, normal) |
2009-02-13T14:53:27+01:00 | 13.02.2009

The problem I encountered is the following :
When trying to retrieve the year of this date with the following code :

$this -> get(Zend_Date::YEAR)

I obtained the value 07 although  the same operation made on the $today date
returned the value 2007.

In one of the methods of the Fxc_Date_Public class, I use this code to get
the year of the date, which I give to a PHP's native function, so I really
need to have the entire format of the year.

To solve it, I used the operator clone instead of :

$candidate = $this -> getDate();

but I think it would be better if I could obtain the same result (with a
time part set to 00:00:00 so) with the getDate() method.

I hope that I was enough clear and that I was rather clearly.

Regards,

Julien.
-- 
View this message in context: 
http://www.nabble.com/Zend_Date%3A%3AgetDate%28%29-don%27t-return-a-clone-in-the-DATE_MEDIUM-format-tf3490792s16154.html#a9748750
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to