php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68066 blank locale in IntlDateFormatter::formatObject return international format
Submitted: 2014-09-20 23:14 UTC Modified: 2018-04-08 17:27 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dgoosens at gmail dot com Assigned:
Status: Open Package: I18N and L10N related
PHP Version: Irrelevant OS: Ubuntu 14.04
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: dgoosens at gmail dot com
New email:
PHP Version: OS:

 

 [2014-09-20 23:14 UTC] dgoosens at gmail dot com
Description:
------------
when passing a blank space instead of NULL or a valid locale, the \IntlDateFormatter::formatObject returns an international formatted string...

I'm thinking this is the apropriate behavior but it is not documented...

Documentation states :
[http://be2.php.net/manual/en/intldateformatter.formatobject.php]
 locale
    The locale to use, or NULL to use the default one.



Test script:
---------------
<?php
	
	$dateTime = new \DateTime();

	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::NONE, null);
	echo PHP_EOL;
	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::NONE, '');
	echo PHP_EOL;
	echo PHP_EOL;


	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::SHORT, null);
	echo PHP_EOL;
	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::SHORT, '');
	echo PHP_EOL;
	echo PHP_EOL;


	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::MEDIUM, null);
	echo PHP_EOL;
	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::MEDIUM, '');
	echo PHP_EOL;
	echo PHP_EOL;


	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::LONG, null);
	echo PHP_EOL;
	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::LONG, '');
	echo PHP_EOL;
	echo PHP_EOL;


	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::FULL, null);
	echo PHP_EOL;
	echo \IntlDateFormatter::formatObject($dateTime, \IntlDateFormatter::FULL, '');




Expected result:
----------------
Either the script should throw a warning or the documentation needs an update to illustrate the actual behavior

Actual result:
--------------
20140921 01:04 AM
20140921 01:04 AM

9/21/14, 1:04 AM
2014-09-21 01:04

Sep 21, 2014, 1:04:40 AM
2014 M09 21 01:04:40

September 21, 2014 at 1:04:40 AM GMT+2
2014 M09 21 01:04:40 GMT+2

Sunday, September 21, 2014 at 1:04:40 AM Central European Summer Time
2014 M09 21, Sun 01:04:40 GMT+02:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-08 17:27 UTC] cmb@php.net
If a string is passed as $locale, it is passed along unmodified to
Locale::createFromName().  However, the documentation for this
method does not specify what happens if an empty string is passed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC