Strtotime function returns false when passing a FrozenTime object

I am using CakePHP 4 and PHP 8. I get the correct result when I pass a FrozenTime object to strtotime function on a Windows server. but on a Linux server, I get False for the below code:

print_r(strtotime(new FrozenTime()));

Although strtotime(new FrozenDate()) works as usual.

Maybe a different version of the ICU library on the two servers? But why use strtotime at all? If you want the current timestamp, FrozenTime::now()->timestamp should give that to you faster.

Thank you, this has been working fine when I had PHP 7.4 in both Windows and Linux. This bug appeared after I upgraded the PHP version. On the Windows machine, the ICU version is 70.1. And on Linux it is 72.1

And sorry the strtotime(new FrozenTime()) was just an example, I am actually trying to get the strtotime of a FrozenTime object that I am fetching from the database.

Another thing is when I print_r(new FrozenTime()->i18nFormat()), I get 5/30/23, 1:54 a.m. on the Linux server. And when I paste this in the VS code, I see the message The character U+202f is invisible between 1:54 and a.m.
And when I remove that character, strtotime function works properly on the Linux server.

Again, no need to use strtotime, just use ->timestamp on whatever your date variable is.

1 Like

That was a spectacularly stupid move on ICU’s part, in ICU 72 they changed (among others) some whitespace to NBSP and some hyphen to NDASH, which caused so much trouble downstream, lots of projects had to implement workarounds to undo the new behavior.

1 Like

Adding a few more related links: