Zend Date Weirdness - Missing Configuration?

Zend Date's getDate method is easy to misunderstand. Its output is really not to be used except to compare with another getDate output, and only to see how two dates compare vis-a-vis their calendar date. Consider it a "calendar date hash function Example (good): do these two dates fall on the same calendar date?

$date1->getDate()->equals($date2->getDate()); // works as expected Example (bad): echo $date1->getDate(); // is meaningless echo $date1->getCalendarDateHash(); // just as this would be $date1 = $date1->getDate(); // and don't store this meaningless value If you're looking for it to set the time part to 00:00:00, look elsewhere.

Zend Date's getDate method is easy to misunderstand. Its output is really not to be used except to compare with another getDate output, and only to see how two dates compare vis-a-vis their calendar date. Consider it a "calendar date hash function".

Example (good): do these two dates fall on the same calendar date? $date1->getDate()->equals($date2->getDate()); // works as expected Example (bad): echo $date1->getDate(); // is meaningless echo $date1->getCalendarDateHash(); // just as this would be $date1 = $date1->getDate(); // and don't store this meaningless value If you're looking for it to set the time part to 00:00:00, look elsewhere.

Good to know why it's behaving that way. It should be documented more clearly. – Sonny Mar 10 at 17:27.

That does work for output, but it doesn't return a Zend_Date object stripped of the time parts. – Sonny Jun 24 '10 at 16:41 from the manual: The getDate() method parses strings containing dates in localized formats. The results are returned in a structured array, with well-defined keys for each part of the date.

– ArneRie Jun 24 '10 at 16:44 You're referring to Zend_Locale_Format::getDate(). The getDate() function in Zend_Date is documented like this: Returns a clone of $this, with the time part set to 00:00:00. – Sonny Jun 24 '10 at 17:37.

See zendframework. Com/issues/browse/ZF-4490 – Ashley Jun 24 '10 at 22:07 I am on 1.10.5. If you look at the last comment on that bug, another person is seeing the same behavior as me.

I just wasn't sure if we both were doing the same thing wrong since there was no reply to that comment. – Sonny Jun 24 '10 at 22:17 1 Same version as you, same problem here. The only way around it is to use the set method, or revert back to the 0 timezone.

Set is probably better. I'd make my own class and extend Zend_Date, that way you won't have to keep remembering to reset it Edit.. just seen you already have – Ashley 1.101 at 8:42.

This isn't really an answer to my question, but this is my workaround. I have extended the Zend_Date class as follows: 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(); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions