Bug #69150 [Com]: DateTime object does not update micro seconds
Edit report at https://bugs.php.net/bug.php?id=69150&edit=1
ID: 69150
Comment by: cmbecker69 at gmx dot de
Reported by: remyfox at hotmail dot com
Summary: DateTime object does not update micro seconds
Status: Open
Type: Bug
Package: Date/time related
Operating System: Windows 7
PHP Version: 5.6.6
Block user comment: N
Private report: N
New Comment:
This is not a bug.
It is documented that DateTime::setTimestamp()[1] expects a Unix
timestamp as int argument. Any float passed to this method is
casted to integer.
[1] <http://php.net/manual/en/datetime.settimestamp.php>
Previous Comments:
------------------------------------------------------------------------
[2015-02-28 23:47:47] remyfox at hotmail dot com
Description:
------------
Micro seconds on the date property (and consequently, formatted output) do not update after the
initial creation of the DateTime object.
Test script:
---------------
$datetime = Datetime::createFromFormat('Y-m-d H:i:s.u', '2009-02-09
15:16:17.015750');
$datetime->setTimeStamp(0);
print_r($datetime);
$datetime = Datetime::createFromFormat('Y-m-d H:i:s', '2009-02-09 15:16:17');
$datetime->setTimeStamp(0.123);
print_r($datetime);
Expected result:
----------------
DateTime Object
(
[date] => 1970-01-01 01:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
DateTime Object
(
[date] => 1970-01-01 01:00:00.123000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
Actual result:
--------------
DateTime Object
(
[date] => 1970-01-01 01:00:00.015750
[timezone_type] => 3
[timezone] => Europe/Berlin
)
DateTime Object
(
[date] => 1970-01-01 01:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69150&edit=1
Thread (3 messages)