Issue

ZF-10584: Zend_Date::setTime doesn't check if dst change

Issue Type: Bug Created: 2010-10-20T15:10:24.000+0000 Last Updated: 2012-10-29T11:34:26.000+0000 Status: Open Fix version(s): Reporter: Piotr Dabrowiecki (pdabrowiecki) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments:

Description

calling method Zend_Date::setTime("08:00:00") on date "2010-10-31 00:00:00" results with date "2010-10-31 07:00:00". This is because of dst change.

Comments

Posted by Adam George (asgeo1) on 2011-04-06T05:11:17.000+0000

I'm having this same problem. I'm in timezone "Australia/Melbourne"

Daylight savings finished on 3-Apr-2011 and so we lost the hour between 2am-3am on that day.

This code triggers the problem for me:

<pre class="highlight">
date_default_timezone_set('Australia/Melbourne');

$date = new Zend_Date('03-Apr-2011', 'dd/MMM/yyyy');
$date->setHour(6);

echo $date->getIso();

//2011-04-03T05:00:00+10:00a:1301749200

I think the priority should be bumped up. A bug like this in setHour/setTime means you can't really use the function for a lot of things.

Posted by Adam George (asgeo1) on 2011-04-06T05:22:29.000+0000

Sorry, I mean we gained an hour that day.

Posted by Edward "Sonny" Savage (sonnysavage) on 2011-08-24T19:56:32.000+0000

I just spent several hours tracking this down in my calendar application.

<pre class="highlight">
date_default_timezone_set('America/New_York');

echo '


';

$a = new Zend_Date('2012-03-11 00:00:00', 'yyyy-MM-dd HH:mm:ss');
$a->setTime('04:00:00', 'HH:mm:ss');
echo $a->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-03-11 04:00:00' . PHP_EOL;

$b = new Zend_Date('2012-03-11 04:00:00', 'yyyy-MM-dd HH:mm:ss');
$b->setTime('00:00:00', 'HH:mm:ss');
echo $b->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-03-11 00:00:00' . PHP_EOL;

$c = new Zend_Date('2012-11-04 00:00:00', 'yyyy-MM-dd HH:mm:ss');
$c->setTime('04:00:00', 'HH:mm:ss');
echo $c->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-11-06 04:00:00' . PHP_EOL;

$d = new Zend_Date('2012-11-04 04:00:00', 'yyyy-MM-dd HH:mm:ss');
$d->setTime('00:00:00', 'HH:mm:ss');
echo $d->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-11-06 00:00:00' . PHP_EOL;

echo '

';


<pre class="literal">
2012-03-11 05:00:00 // expected: 2012-03-11 04:00:00
2012-03-10 23:00:00 // expected: 2012-03-11 00:00:00
2012-11-04 03:00:00 // expected: 2012-11-06 04:00:00
2012-11-04 01:00:00 // expected: 2012-11-06 00:00:00

Posted by Edward "Sonny" Savage (sonnysavage) on 2011-08-24T20:08:17.000+0000

Why is this marked as minor? I'm not sure how to work around it.

Posted by Edward "Sonny" Savage (sonnysavage) on 2011-08-25T13:26:05.000+0000

I posted on Stack Overflow, and have a work around for now. It's far from optimal. This really needs to be fixed. http://stackoverflow.com/questions/7181702/…

Posted by Stéphane (stephane) on 2012-10-29T11:34:26.000+0000

Upvoted. It would be really nice to have a fix for this.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2022 by Zend by Perforce. Made with by awesome contributors.

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

Contacts