php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74258 Microseconds are missing in DateTime class
Submitted: 2017-03-17 07:35 UTC Modified: 2017-03-21 16:26 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:3 (50.0%)
From: dawid dot lakomski at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1.3 OS: Ubuntu 16.04
Private report: No CVE-ID: None
 [2017-03-17 07:35 UTC] dawid dot lakomski at gmail dot com
Description:
------------
After upgrading to PHP 7.1.3 I noticed that microseconds are now missing from DateTime objects.

Test script:
---------------
<?php
var_dump(new \DateTime());

Expected result:
----------------
Microseconds part of $date field should not be 000000 (or not always ;) )

Actual result:
--------------
class DateTime#1 (3) {
  public $date =>
  string(26) "2017-03-17 08:25:48.000000"
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(13) "Europe/Berlin"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-18 06:40 UTC] malte dot blaettermann at gmail dot com
Maybe this commit has introduced the bug?

https://github.com/php/php-src/commit/5113909259f897c9c69f23cf5f8f7ab8972d5eba
 [2017-03-21 16:04 UTC] fox91fox at gmail dot com
I have the same issue inside official Docker image.

Test script:
------------
<?php
echo (new DateTimeImmutable('now'))->format('H:i:s.u');

Results:
--------
PHP 7.0.17: 15:53:06.000000
PHP 7.1.0:  15:53:26.871760
PHP 7.1.1:  15:53:38.272202
PHP 7.1.2:  15:53:48.824298
PHP 7.1.3:  15:54:03.000000

I've tested multiple times every version.
 [2017-03-21 16:16 UTC] sjon at hortensius dot net
Thanks for reporting, this will be fixed in 7.1.4

Fixed in https://github.com/php/php-src/commit/2b7c3831cdc9a0e708040af37d8cf8967755bce3
 [2017-03-21 16:26 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC