Skip to content

Date displaying 2012/12/31 #45

Closed
zfbot opened this Issue Apr 5, 2013 · 5 comments

3 participants

@zfbot
zfbot commented Apr 5, 2013

Jira Information

Original Issue: ZF-12499
Issue Type: Bug
Reporter: Erembert Dubal Teddy
Created: 01/04/13
Assignee:
Components: Zend_Date

Description

The problem is about displaying of the 2012/12/31

For exemple :
$date = new Zend_Date('2012-12-31', 'Y-MM-dd');

echo $date->toString();
// 31 déc. 2012 00:00:00 my locale is FR it's good

echo $date->toString('Y-MM-dd');
// 2013-12-31 the result it's false

@zfbot
zfbot commented Apr 5, 2013

(Originally posted by: Peter Moolenaar on 01/12/13)

Probably a dupe of ZF-5297. Use of a lowercase y should solve it.

@zfbot
zfbot commented Apr 5, 2013

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF-12499

Known GitHub users mentioned in the original message or comment:

@jeremyquinton

I installed the french locale on the ubuntu vagrant machine for ZF1

/usr/sbin/locale-gen fr_FR.*

locale -a will list the locales

I then ran the code snippet below on PHP 5.2.17, 5.3.26 and 5.4.16

include('/vagrant/library/Zend/Date.php');
setlocale(LC_ALL, 'fr_FR'); 

$date = new Zend_Date('2012-12-31', 'Y-MM-dd');
echo $date->toString() . PHP_EOL;
echo $date->toString('Y-MM-dd') . PHP_EOL;

Results

vagrant@zf1:/vagrant$ /usr/local/php/5.2.17/bin/php datetest.php
31 déc. 2012 00:00:00
2012-12-31
vagrant@zf1:/vagrant$ /usr/local/php/5.3.26/bin/php datetest.php
31 déc. 2012 00:00:00
2012-12-31
vagrant@zf1:/vagrant$ /usr/local/php/5.4.16/bin/php datetest.php
31 déc. 2012 00:00:00
2012-12-31

As far as I can see this is no longer an issue? Anymore info on the environment might help could be a specific version of PHP or linux distro.

@froschdesign
Zend Framework member

This is no longer a problem.

Here is a simple unit test:

public function testFrenchDate()
{
    $locale = new Zend_Locale('fr_FR');

    require_once 'Zend/Registry.php';
    Zend_Registry::set('Zend_Locale', $locale);

    $date = new Zend_Date('2012-12-31', 'Y-MM-dd');

    $this->assertEquals('fr_FR', $date->getLocale());
    $this->assertEquals('31 déc. 2012 00:00:00', $date->toString());
    $this->assertEquals('2012-12-31', $date->toString('Y-MM-dd'));
}

Result: Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.