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.

https://github.com/WebKit/WebKit/pull/10012
https://hg.mozilla.org/mozilla-central/rev/40e2c54d5618
https://chromium.googlesource.com/v8/v8/+/bab790f9165f65a44845b4383c8df7c6c32cf4b3
https://github.com/nodejs/node/pull/46646

1 Like

Adding a few more related links:

https://www.reddit.com/r/webdev/comments/1054ve6/psa_node_1813_changed_datetime_formatting/

https://github.com/nodejs/node/issues/46123

And
https://github.com/folio-org/stripes-components/commit/17f75f1ee0ce8837fb84a81c0f7ee4cab248272a