php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76190 \DateTime::__construct with microsecond failed with setlocale
Submitted: 2018-04-06 09:31 UTC Modified: 2018-04-07 18:38 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: nicolas dot levee at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: 7.0.27, 7.1.16 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nicolas dot levee at gmail dot com
New email:
PHP Version: OS:

 

 [2018-04-06 09:31 UTC] nicolas dot levee at gmail dot com
Description:
------------
My PHP Version 7.0.26

The \DateTime::__construct failed to format microsecond on Apache SAPI but succeed on CLI

Test script:
---------------
echo (new \DateTime("2018-04-06 09:42:14.999273"))->format("U.u");

Expected result:
----------------
1523000534.999273

Actual result:
--------------
1523000534.000000

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-06 10:22 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2018-04-06 10:22 UTC] requinix@php.net
The SAPI shouldn't matter. Are you sure you have the same version of PHP for both?
 [2018-04-06 10:31 UTC] nicolas dot levee at gmail dot com
-Status: Feedback +Status: Open -PHP Version: 7.0.29 +PHP Version: 7.0.27
 [2018-04-06 10:31 UTC] nicolas dot levee at gmail dot com
I have the same version on both. I'm using a Docker manualy configured on Debian 9

And I have the same problem with php 7.1.16.

Here my package list : 
ii  apache2                          2.4.25-3+deb9u4                amd64        Apache HTTP Server
ii  apache2-bin                      2.4.25-3+deb9u4                amd64        Apache HTTP Server (modules and other binary files)
ii  apache2-data                     2.4.25-3+deb9u4                all          Apache HTTP Server (common files)
ii  apache2-utils                    2.4.25-3+deb9u4                amd64        Apache HTTP Server (utility programs for web servers)
ii  libapache2-mod-php7.0            7.0.27-0+deb9u1                amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-apcu                         5.1.8+4.0.11-1                 amd64        APC User Cache for PHP
ii  php-apcu-bc                      1.0.3-2                        amd64        APCu Backwards Compatibility Module
ii  php-common                       1:49                           all          Common files for PHP packages
ii  php-imagick                      3.4.3~rc2-2                    amd64        Provides a wrapper to the ImageMagick library
ii  php-pear                         1:1.10.1+submodules+notgz-9    all          PEAR Base System
ii  php-xml                          1:7.0+49                       all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php7.0                           7.0.27-0+deb9u1                all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.0-bcmath                    7.0.27-0+deb9u1                amd64        Bcmath module for PHP
ii  php7.0-cli                       7.0.27-0+deb9u1                amd64        command-line interpreter for the PHP scripting language
ii  php7.0-common                    7.0.27-0+deb9u1                amd64        documentation, examples and common module for PHP
ii  php7.0-curl                      7.0.27-0+deb9u1                amd64        CURL module for PHP
ii  php7.0-dev                       7.0.27-0+deb9u1                amd64        Files for PHP7.0 module development
ii  php7.0-fpm                       7.0.27-0+deb9u1                amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.0-gd                        7.0.27-0+deb9u1                amd64        GD module for PHP
ii  php7.0-intl                      7.0.27-0+deb9u1                amd64        Internationalisation module for PHP
ii  php7.0-json                      7.0.27-0+deb9u1                amd64        JSON module for PHP
ii  php7.0-mbstring                  7.0.27-0+deb9u1                amd64        MBSTRING module for PHP
ii  php7.0-mcrypt                    7.0.27-0+deb9u1                amd64        libmcrypt module for PHP
ii  php7.0-mysql                     7.0.27-0+deb9u1                amd64        MySQL module for PHP
ii  php7.0-opcache                   7.0.27-0+deb9u1                amd64        Zend OpCache module for PHP
ii  php7.0-readline                  7.0.27-0+deb9u1                amd64        readline module for PHP
ii  php7.0-soap                      7.0.27-0+deb9u1                amd64        SOAP module for PHP
ii  php7.0-xml                       7.0.27-0+deb9u1                amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii  php7.0-zip                       7.0.27-0+deb9u1                amd64        Zip module for PHP


Hop this can help
 [2018-04-06 20:43 UTC] nicolas dot levee at gmail dot com
-Summary: \DateTime::__construct with microsecond failed +Summary: \DateTime::__construct with microsecond failed with setlocale -PHP Version: 7.0.27 +PHP Version: 7.0.27, 7.1.16
 [2018-04-06 20:43 UTC] nicolas dot levee at gmail dot com
I find something, if i change the locale to :

```
setlocale(LC_ALL, 'fr_FR.UTF-8');
```

it's failed, if I let the default locale the function work properly
 [2018-04-07 18:38 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-04-07 18:38 UTC] cmb@php.net
Duplicate of bug #67127.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC