|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 04:00:02 2025 UTC |
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"}