php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67646 DateTime return with microsecond in default
Submitted: 2014-07-18 02:23 UTC Modified: 2014-08-14 02:05 UTC
Votes:6
Avg. Score:3.5 ± 1.4
Reproduced:4 of 5 (80.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: lukyrys at gmail dot com Assigned:
Status: Not a bug Package: date_time (PECL)
PHP Version: 5.5.14 OS: Debian 7.5
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: lukyrys at gmail dot com
New email:
PHP Version: OS:

 

 [2014-07-18 02:23 UTC] lukyrys at gmail dot com
Description:
------------
Why microseconds? Is there any option to disable it? Its new at 5.5.14.




Test script:
---------------
<?php
error_reporting(E_ALL);
$x = new DateTime('now');
$y = new DateTime($x->format('d.m.Y'));
$y->format("Y-m-d H:i:s");

$d = unserialize(serialize($x));


var_dump($d);
var_dump( unserialize(serialize ($y)) );




Expected result:
----------------
object(DateTime)#3 (3) {
  ["date"]=>
  string(26) "2014-07-18 04:20:50"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Prague"
}
object(DateTime)#4 (3) {
  ["date"]=>
  string(26) "2014-07-18 00:00:00"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Prague"
}

Actual result:
--------------
object(DateTime)#3 (3) {
  ["date"]=>
  string(26) "2014-07-18 04:20:50.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Prague"
}
object(DateTime)#4 (3) {
  ["date"]=>
  string(26) "2014-07-18 00:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Prague"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-13 14:18 UTC] dmitry dot balabka at gmail dot com
This bug also can be reproduced in 5.4.30, 5.4.31
 [2014-08-13 14:54 UTC] dmitry dot balabka at gmail dot com
I guess it should be fixed at least because object serialization into JSON differs:

PHP 5.4.28
echo json_encode(new \DateTime());
{"date":"2014-08-13 09:53:07","timezone_type":3,"timezone":"America\/Chicago"}

PHP 5.4.31
echo json_encode(new \DateTime());
{"date":"2014-08-13 17:48:55.000000","timezone_type":3,"timezone":"Europe\/Riga"}
 [2014-08-13 15:37 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2014-08-13 15:37 UTC] pajoye@php.net
please report  bug in the php's date and time functions. This is not the right category and I cannot change it.
 [2014-08-14 02:05 UTC] lukyrys at gmail dot com
Added at - https://bugs.php.net/bug.php?id=67838

Thx
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 14:01:27 2025 UTC