Skip to content
Advertisement

DateTime(‘now’) not modified after sleep()

I have following code

JavaScript

I expected to get each line different time. surprisingly the output is like this.

JavaScript

I suspected it is the buffer flush problem so added $string variables but it is still the same. Can anyone explain why it happens? Thanks.

Regards, Marcin

Advertisement

Answer

The ‘now’ parameter is simply ignored. This is also documented in the PHP manual. When creating with

JavaScript

It doesn’t matter whether the parameter is “now” or none.

My recommendation: Always recreate the current time with new DateTime.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement