Issue Type: Bug Created: 2008-10-05T02:40:02.000+0000 Last Updated: 2011-09-07T16:01:28.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)
Reporter: Jaka Jancar (jaka) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date
Related issues: Attachments:
For Zend_Dates in a timezone other than UTC, getDate() doesn't return a date with 0 time part, as described in docu, but instead 0 + time zone base offset (without DST).
I don't know if this is intended or not. If it is, it should be documented in the documentation.
Example of when this is a problem: You have a set of objects and want to select only those whose time property is today. So you filter using (time >= Zend_Date::now()- >getDate()->getTimestamp() && time < ...). But this will not display what the user considers "today" (what is today in the current timezone).
<pre class="highlight"> $ php <?php require_once 'Zend/Date.php'; date_default_timezone_set('Europe/Ljubljana'); $date = Zend_Date::now(); echo $date.PHP_EOL; echo $date->getDate().PHP_EOL; Oct 5, 2008 11:29:00 AM Oct 5, 2008 1:00:00 AM
Posted by Jaka Jancar (jaka) on 2008-10-05T02:51:25.000+0000
Given the docu (??Returns a clone of $this, with the time part set to 00:00:00.??), I would expect it to work the same as this:
<pre class="highlight"> $ php <?php require_once 'Zend/Date.php'; date_default_timezone_set('Europe/Ljubljana'); $date = Zend_Date::now(); echo $date.PHP_EOL; $date->set(0, 'HOUR'); $date->set(0, 'MINUTE'); $date->set(0, 'SECOND'); $date->set(0, 'MILLISECOND'); echo $date.PHP_EOL; Oct 5, 2008 11:48:53 AM Oct 5, 2008 12:00:00 AM
Posted by Thomas Weidner (thomas) on 2008-11-10T12:16:05.000+0000
Fixed with r12524 in trunk
Posted by Wil Sinclair (wil) on 2008-11-13T14:10:23.000+0000
Changing issues in preparation for the 1.7.0 release.
Posted by Lauri Kotilainen (rytmis) on 2009-08-09T06:38:46.000+0000
Repro in Zend 1.8.1:
<pre class="literal"> <?php require_once('Zend/Date.php'); date_default_timezone_set('Europe/Helsinki'); $date = Zend_Date::now()->getDate(); echo $date->toString() . PHP_EOL;
Posted by Holger Schletz (hschletz) on 2011-09-07T16:01:28.000+0000
The bug still persists as of 1.11.10. Precisely, the result of getDate() is 1 hour off when DST is in effect for the given date. For dates without DST or when the timezone is set to UTC/GMT, the result is correct. Example:
<pre class="literal">date_default_timezone_set('Europe/Berlin'); // DST in effect: result incorrect $date = new Zend_Date('2010-06-20 14:56:33'); $date = $date->getDate(); echo $date->toString() . PHP_EOL; // no DST in effect: result correct $date = new Zend_Date('2010-12-20 14:56:33'); $date = $date->getDate(); echo $date->toString() . PHP_EOL;
<pre class="literal">19.06.2010 23:00:00 20.12.2010 00:00:00
The substitute solution with setting the time to midnight works either way. getDate() itself is currently unusable for DST-aware timezones.
The unit test only checks for 2002-01-04 (no DST) and therefore succeeds. A second check with a DST date is required for a full test. Additionally, the checks should be performed with timezone set to both UTC and a DST-aware timezone. The current test appears to use Indian/Maldives, which did NOT show the erratic behavior with my own test script. No DST on the maldives, I suppose. I'd recommend a timezone that is more than 1 hour away from UTC, so that it's clear whether the offset comes from the timezone or from DST.
The inconsistency of this bug's history may result from the use of Zend_Date::now() for testing. The reports come from mid-October and August (DST in effect), while the fix was made in November (no DST, no erratic behavior).
Have you found an issue?
See the Overview section for more details.