|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-10-14 13:55 UTC] dse at newpharma dot ro
Description:
------------
Adding or subtracting milliseconds from a DateTime object does not give the correct result.
Test script:
---------------
<?php
$millisInThePast = 50000;
$currentDate = new DateTime("2019-10-14T15:08:23.123+02:00");
echo 'Current: ' . $currentDate->format(DATE_RFC3339_EXTENDED) . "\n";
echo 'Past: ' . $currentDate->modify("-{$millisInThePast} msec")->format(DATE_RFC3339_EXTENDED);
Expected result:
----------------
Current: 2019-10-14T15:08:23.123+02:00
Past: 2019-10-14T15:07:33.123+02:00
Actual result:
--------------
Current: 2019-10-14T15:08:23.123+02:00
Past: 2019-10-14T15:08:21.-47877+02:00
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 11:00:01 2025 UTC |
The code definitely normalizes the fractions: void timelib_do_normalize(timelib_time* time) { if (time->us != TIMELIB_UNSET) do_range_limit_fraction(&time->us, &time->s); So I'm going to have to see why this doesn't work.