|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-05-14 08:17 UTC] info at programmiernutte dot net
Description:
------------
After upgrading to 5.3.0 RC2, date('Y') always returns 0000. No php.ini setting (date.timezone) seems to have any influence.
date('y') works as expected and returns 09.
This Problem did not occur with 5.3.0RC1.
Reproduce code:
---------------
marvin:~/src/php-5.3.0RC2 thomas$ ./sapi/cli/php
<?=date('Y') ?>
0000
Expected result:
----------------
marvin:~/src/php-5.3.0RC2 thomas$ ./sapi/cli/php
<?=date('Y') ?>
2009
Actual result:
--------------
marvin:~/src/php-5.3.0RC2 thomas$ ./sapi/cli/php
<?=date('Y') ?>
0000
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 21:00:01 2025 UTC |
DateTime is also affected: $oDateTime = new DateTime(); print_r($oDateTime); Result: DateTime Object ( [date] => 0000-05-24 21:27:10 [timezone_type] => 3 [timezone] => Europe/Berlin )I cannot reproduce this on OS X 10.5.7 with PHP 5.3.0RC2. $oDateTime = new DateTime(); print_r($oDateTime); Result: DateTime Object ( [date] => 2009-05-27 14:57:33 [timezone_type] => 3 [timezone] => America/Phoenix ) echo date('y'); Result: 09 echo date('Y'); Result: 2009Seems like it's an issue in slprintf: 1017 switch (format[i]) { (gdb) 1043 timelib_sll year = PHP_LLABS(t->y); (gdb) print year $1 = 1230768000 (gdb) next 1044 length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", year); break; (gdb) print year $2 = 2009 (gdb) next 1124 smart_str_appendl(&string, buffer, length); (gdb) print buffer $3 = "0000\000\000\004\202\000\000\000\000\000\000\000\000I\\\a\200\000\000\000\000\000\000\0006\000\000\000\000" (gdb) next 1015 for (i = 0; i < format_len; i++) { (gdb) print &string $4 = (smart_str *) 0xffa1cde0 (gdb) print string $5 = {c = 0x1071f060 "0000\020q�X\020c\003�", len = 4, a = 78}This bug still exits in the same way with PHP 5.2.10. Found after upgrade from 5.2.9 to 5.2.10 on a Mac OS X 10.4.11 Server PPC. With 5.2.9 <?=date(Y); ?> works as expected.Also, seeing this after upgrading from 5.2.9 to 5.2.10. On Solaris Sparc version 9. <?=date(Y); ?> returns 0000 on 5.2.10 and returns 2009 as expected on 5.2.9