Issues

ZF-10358: Zend_Date improperly recognize year when date with custom format is created

Issue Type: Bug Created: 2010-08-21T14:39:41.000+0000 Last Updated: 2011-09-06T20:03:42.000+0000 Status: Open Fix version(s): Reporter: Ondrej Machulda (ondram) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments: - 10358.patch

Description

There is an issue while creating new Zend_Date with specific format being set, in this case Twitter-specific date format (in which is e.g. 'created_at' field of zend_service_twitter response).

The date in its pure form is eg. "Sat Aug 21 18:50:20 +0000 2010", which corresponds to the format "EEE MMM d H:m:s ZZZ yyy" in en_US locale.

Example: $date = new Zend_Date("Sat Aug 21 18:50:20 +0000 2010", 'EEE MMM d H:m:s ZZZ yyy', 'en_US'); echo $date->get(Zend_Date::ISO_8601);

Expected output: 2010-08-21T18:50:20+00:00

Current output: 2000-08-21T18:50:20+00:00 // the year is 2000 instead of 2010

Comments

Posted by Andreas Heigl (heiglandreas) on 2010-08-22T23:48:45.000+0000

Shouldn't it read $date = new Zend_Date("Sat Aug 21 18:50:20 +0000 2010", "EEE MMM d H:m:s ZZZ yyyy", 'en_US');?

Posted by Ondrej Machulda (ondram) on 2010-08-23T04:26:41.000+0000

In fact, in this case is the output weird as well:

0-08-21T18:50:20+00:00

Looks like the year is not recognized at all...

Posted by Christoph Kempen (webpatser) on 2011-04-24T22:09:15.000+0000

same happens in ZF 1.11.5

This is my workaround:

<pre class="highlight">
$date = new Zend_Date( strtotime($tweet['created_at']) );

Posted by Lucas Corbeaux (lucas.corbeaux@gmail.com) on 2011-09-06T20:03:42.000+0000

Still happens in 1.11.10.

The problem seems to be in Zend_Locale_Format : the _parseDate() method ignore the ZZZZ format, but consider the date part 0000 as the year instead of 2010.

I add a patch that solves the problem for me.

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