#47312 [Asn]: Calling setlocale causes microseconds to disappear

From: Date: Sun, 10 May 2009 17:38:49 +0000
Subject: #47312 [Asn]: Calling setlocale causes microseconds to disappear
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137125@lists.php.net to get a copy of this message
 ID:               47312
 Updated by:       jani@php.net
 Reported By:      robert dot johnson at icap dot com
 Status:           Assigned
 Bug Type:         Date/time related
-Operating System: Win XP sp3
+Operating System: *
-PHP Version:      5.2.8
+PHP Version:      5.*, 6CVS (2009-05-09)
 Assigned To:      derick
 New Comment:

See also bug #48225



Previous Comments:
------------------------------------------------------------------------

[2009-02-04 19:49:04] derick@php.net

Found why... now looking for a fix.

------------------------------------------------------------------------

[2009-02-04 19:42:57] derick@php.net

Never mind, missed that.

------------------------------------------------------------------------

[2009-02-04 19:42:10] derick@php.net

What is:
CLocale::DateTimeFormatFull

------------------------------------------------------------------------

[2009-02-04 19:28:58] robert dot johnson at icap dot com

CLocale::DateTimeFormatFull == 'd/m/Y H:i:s.u'

------------------------------------------------------------------------

[2009-02-04 19:26:33] robert dot johnson at icap dot com

Description:
------------
I changed locale to Germany, created a datetime with microseconds,
formatted the date, and the microseconds were zero.

This first appeared when SQL 2005 driver showed no microseconds for
German users of my site.

The code is a simple test to show it's not caused by the SQL Server
driver.

Reproduce code:
---------------
$robert = new DateTime('2009-02-04 15:55:25.321');
$robertf = $robert->format(CLocale::DateTimeFormatFull);
echo $robertf . "\r\n";

$robloc = setlocale(LC_ALL, 'German_Germany.1252');
echo $robloc . "\r\n";
$robert = new DateTime('2009-02-04 15:55:25.321');
$robertf = $robert->format(CLocale::DateTimeFormatFull);
echo $robertf . "\r\n";

$robloc = setlocale(LC_ALL, 'English_uk.1252');
echo $robloc . "\r\n";
$robert = new DateTime('2009-02-04 15:55:25.321');
$robertf = $robert->format(CLocale::DateTimeFormatFull);
echo $robertf . "\r\n";;

Expected result:
----------------
04/02/2009 15:55:25.321000
German_Germany.1252
04/02/2009 15:55:25.321000
English_United Kingdom.1252
04/02/2009 15:55:25.321000


Actual result:
--------------
04/02/2009 15:55:25.321000
German_Germany.1252
04/02/2009 15:55:25.000000
English_United Kingdom.1252
04/02/2009 15:55:25.321000



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47312&edit=1



Thread (7 messages)

« previous php.bugs (#137125) next »