If I have an object of type DateTime how I can add some milliseconds?
$date = new Datetime("2016-09-23T20:48:16.090Z");
// how to add to this date 9 milliseconds?
If I have an object of type DateTime how I can add some milliseconds?
$date = new Datetime("2016-09-23T20:48:16.090Z");
// how to add to this date 9 milliseconds?
As of PHP 7.1, milliseconds and microseconds can also be easily added to DateTime using the modify method.
$date = new Datetime("2016-09-23T20:48:16.090Z");
$millisec = 9;
$date->modify('+ '.$millisec.' milliseconds');
var_dump($date);
Output:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2016-09-23 20:48:16.099000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}