0

I want to increase time by 10 milliseconds on every time execution of a loop.

$new_ts = "2015-07-01 14:16:31.000000";
for($i=0;$i<10;$i++){
        echo $new_ts."<br>";
        $ts = strtotime($new_ts);
        $new_ts = date('Y-m-d H:i:s.u', $ts + 0.100000);
}

It generates output like

2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000
2015-07-01 14:16:31.000000

Albzi
  • 15,431
  • 6
  • 46
  • 63
  • The second parameter of `date` only supports `int` values. Use the `DateTime` class for this. – Daan Jul 01 '15 at 14:42
  • This was definitely flagged incorrectly by mario. The other question asks about how to format a date to display milliseconds, this question asks how to increment milliseconds, which is a whole different and tricky issue. – ksbg Jul 01 '15 at 14:59
  • Hello Mr. Mario please read my question again. i don't want to show millisecond but i want to manipulate the time with respect to milliseconds. And your referenced question is different by this question – PHP Learner Jul 01 '15 at 21:04

0 Answers0