php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47312 Calling setlocale causes microseconds to disappear
Submitted: 2009-02-04 19:26 UTC Modified: 2016-08-07 09:52 UTC
From: robert dot johnson at icap dot com Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.*, 6CVS (2009-05-09) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 + 27 = ?
Subscribe to this entry?

 
 [2009-02-04 19:26 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-04 19:28 UTC] robert dot johnson at icap dot com
CLocale::DateTimeFormatFull == 'd/m/Y H:i:s.u'
 [2009-02-04 19:42 UTC] derick@php.net
What is:
CLocale::DateTimeFormatFull
 [2009-02-04 19:42 UTC] derick@php.net
Never mind, missed that.
 [2009-02-04 19:49 UTC] derick@php.net
Found why... now looking for a fix.
 [2009-05-10 17:38 UTC] jani@php.net
See also bug #48225

 [2016-08-07 09:52 UTC] cmb@php.net
-Status: Assigned +Status: Duplicate
 [2016-08-07 09:52 UTC] cmb@php.net
I'm marking this as duplicate of bug #67127; actually it's the
other way round, but the other ticket already has been analyzed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC