Issues

ZF-5277: fix_dst doesn`t work correctly

Issue Type: Bug Created: 2008-12-16T00:30:14.000+0000 Last Updated: 2008-12-21T05:03:27.000+0000 Status: Resolved Fix version(s): - 1.7.2 (23/Dec/08)

Reporter: Christian Kaps (akkie) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments:

Description

In the following example, the fix_dst option doesn`t work correctly.

<pre class="highlight">
ini_set('date.timezone', 'UTC');

Zend_Date::setOptions(array('fix_dst' => true));

$date = new Zend_Date(mktime(22, 0, 0, 10, 25, 2008));
$date->setTimezone('Europe/Berlin');
$date->add(1, Zend_Date::DAY);
$date->sub(1, Zend_Date::SECOND);
echo $date->get(Zend_Date::DATE_SHORT) . ' ' . $date->get(Zend_Date::TIME_MEDIUM);

Current result: 26.10.08 22:59:59

Expected result: 26.10.08 23:59:59

This bugreport relates to a post in the german ZF-Forum. http://www.zfforum.de/showthread.php?t=2853

When I set the default timezone to Europe\Berlin and not to UTC it works, but this is not the required approach.

Comments

Posted by Thomas Weidner (thomas) on 2008-12-16T01:09:25.000+0000

Debugging your example I get:

<pre class="highlight">
$date = new Zend_Date(mktime(22, 0, 0, 10, 25, 2008));

The date object contains

<pre class="highlight">
2008-10-25T22:00:00+00:00

which is correct... now you set the timezone

<pre class="highlight">
$date->setTimezone('Europe/Berlin');

and the object changes to

<pre class="highlight">
2008-10-26T00:00:00+02:00

which is correct because we are in summertime on this date so GMT+2 Now you add one day

<pre class="highlight">
$date->add(1, Zend_Date::DAY);

but there is a change from summer to wintertime... so the object changes to

<pre class="highlight">
2008-10-26T23:00:00+01:00

because this day has only 23 hours, but also the zone changes to GMT+1 Substracting one second makes no difference

<pre class="highlight">
$date->sub(1, Zend_Date::SECOND);

as the zone does not change on 22-23h.

<pre class="highlight">
2008-10-26T22:59:59+01:00

I see no problem at all.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts