php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53698 datefmt_localtime() and IntlDateFormatter::localtime() causes Fatal Error
Submitted: 2011-01-08 15:53 UTC Modified: 2011-01-08 19:39 UTC
From: t at kahkonen dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.5 OS: Linux 32-bit (Centos 5)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: t at kahkonen dot com
New email:
PHP Version: OS:

 

 [2011-01-08 15:53 UTC] t at kahkonen dot com
Description:
------------
PHP-version: PHP 5.3.3

When executing $arr = datefmt_localtime( $fmt, "Wednesday, December 31, 1969 
4:00:00 PM PT",0), $arr should have parsed day, month, year, hour etc. values, 
but there comes Fatal Error: Only variables can be passed by reference.

Configure Command: './configure'  '--build=i686-redhat-linux-gnu' '--host=i686-
redhat-linux-gnu' '--target=i386-redhat-linux-gnu' 
 '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '-
-sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' 
 '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--
localstatedir=/var' '--sharedstatedir=/usr/com' 
 '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-
file=../config.cache' '--with-libdir=lib' 
 '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--
disable-debug' '--with-pic' '--disable-rpath' 
'--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-
dir=/usr' '--with-png-dir=/usr' 
'--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' 
'--with-gmp' '--with-iconv' 
 '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' 
'--with-layout=GNU' '--enable-exif' 
 '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '-
-enable-sysvshm' '--enable-sysvmsg' 
'--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' 
'--without-mime-magic' '--without-sqlite' 
 '--without-sqlite3' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-
tzdata' '--enable-force-cgi-redirect' 
'--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-
mbstring=shared' '--enable-mbregex' '--with-gd=shared' 
 '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-
xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' 
 '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--
enable-dom=shared' '--with-pgsql=shared' 
'--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-
xsl=shared,/usr' '--enable-xmlreader=shared' 
'--enable-xmlwriter=shared' '--with-curl=shared,/usr' '--enable-fastcgi' '--
enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' 
'--with-pdo-mysql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-
sqlite=shared,/usr' '--with-pdo-dblib=shared,/usr' 
'--enable-json=shared' '--enable-zip=shared' '--with-readline' '--with-
pspell=shared' '--enable-phar=shared' '--with-mcrypt=shared,/usr' 
'--with-tidy=shared,/usr' '--with-mssql=shared,/usr' '--enable-sysvmsg=shared' 
'--enable-sysvshm=shared' '--enable-sysvsem=shared' 
'--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' 
'--enable-intl=shared' '--with-icu-dir=/usr' 
'--with-recode=shared,/usr'



Test script:
---------------
<?php
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
$arr = datefmt_localtime( $fmt, "Wednesday, December 31, 1969 4:00:00 PM PT",0);
echo "First parsed output is ";
if ($arr) {
    foreach ($arr as $key => $value) {
        echo "$key : $value , ";
    }
}
?>

Expected result:
----------------
First parsed output is tm_sec : 0 , tm_min : 0 , tm_hour : 16 , tm_year : 1969 , 
tm_mday : 31 , tm_wday : 4 , tm_yday : 365 , tm_mon : 11 , tm_isdst : 0 , 

Actual result:
--------------
Fatal error: Only variables can be passed by reference in test.php on line 3.

Line 3 has function datefmt_localtime().

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-08 17:02 UTC] t at kahkonen dot com
-Operating System: Linux 32-bit +Operating System: Linux 32-bit (Centos 5)
 [2011-01-08 17:02 UTC] t at kahkonen dot com
Tested with php 5.3.5 and 5.3.3 (identical configure commands): the same Fatal 
Error.

This seems to be a bug and is essential to get working, because I have not found 
any other (easy) way to parse locale independent date/time-strings than 
datefmt_localtime() function. You have to know only user locale (eg. fi_FI.utf8) 
and the program knows how to parse/format correct full, median or short date and 
time for this locale. datefmt_parse() is an other one, but it produces timestamp 
with normal timestamp related problems (for example Year 2038 problem). 
Meanwhile I use my own command line C program which uses directly ICU library, 
but using is rather slow.
 [2011-01-08 17:11 UTC] t at kahkonen dot com
PHP manual page for datefmt_localtime():
http://www.php.net/manual/en/intldateformatter.localtime.php
 [2011-01-08 18:42 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-01-08 18:42 UTC] cataphract@php.net
As the documentation says, you need to pass a variable, so you can't use a literal like the 0 you're passing for the last arg.

Closing as bogus.
 [2011-01-08 19:39 UTC] t at kahkonen dot com
You are right. The documentation is not. I added a note to the page:
http://php.net/manual/en/intldateformatter.localtime.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 24 17:00:01 2025 UTC