# Strtotime function returns false when passing a FrozenTime object

**URL:** <https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242>\
**Category:** Need Help\
**Tags:** i18n\
**Created:** [May 29, 2023, 8:10pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242 "2023-05-29T20:10:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![webdeveloper](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@webdeveloper](https://discourse.cakephp.org/u/webdeveloper)\
**Post date:** [May 29, 2023, 8:10pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/1 "2023-05-29T20:10:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [May 29, 2023, 8:58pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/2 "2023-05-29T20:58:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![webdeveloper](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@webdeveloper](https://discourse.cakephp.org/u/webdeveloper)\
**Post date:** [May 30, 2023, 4:29am UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/3 "2023-05-30T04:29:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![webdeveloper](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@webdeveloper](https://discourse.cakephp.org/u/webdeveloper)\
**Post date:** [May 30, 2023, 5:58am UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/4 "2023-05-30T05:58:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [May 30, 2023, 1:49pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/5 "2023-05-30T13:49:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ndm](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ndm/32/2234_2.png) [@ndm](https://discourse.cakephp.org/u/ndm)\
**Post date:** [May 30, 2023, 4:46pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/6 "2023-05-30T16:46:05Z")

</div>

> [@webdeveloper](#):
>
> […] I see the message `The character `U+202f` is invisible` between `1:54` and `a.m.`

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://github.com/WebKit/WebKit/pull/10012)  
[https://hg.mozilla.org/mozilla-central/rev/40e2c54d5618](https://hg.mozilla.org/mozilla-central/rev/40e2c54d5618)  
[https://chromium.googlesource.com/v8/v8/+/bab790f9165f65a44845b4383c8df7c6c32cf4b3](https://chromium.googlesource.com/v8/v8/+/bab790f9165f65a44845b4383c8df7c6c32cf4b3)  
[https://github.com/nodejs/node/pull/46646](https://github.com/nodejs/node/pull/46646)

---

<div class="post-metadata">

**Author:** ![webdeveloper](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@webdeveloper](https://discourse.cakephp.org/u/webdeveloper)\
**Post date:** [May 30, 2023, 5:01pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/7 "2023-05-30T17:01:54Z")

</div>

Adding a few more related links:

[https://www.reddit.com/r/webdev/comments/1054ve6/psa\_node\_1813\_changed\_datetime\_formatting/](https://www.reddit.com/r/webdev/comments/1054ve6/psa_node_1813_changed_datetime_formatting/)

[https://github.com/nodejs/node/issues/46123](https://github.com/nodejs/node/issues/46123)

---

<div class="post-metadata">

**Author:** ![webdeveloper](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@webdeveloper](https://discourse.cakephp.org/u/webdeveloper)\
**Post date:** [May 30, 2023, 5:02pm UTC](https://discourse.cakephp.org/t/strtotime-function-returns-false-when-passing-a-frozentime-object/11242/8 "2023-05-30T17:02:51Z")

</div>

And  
[https://github.com/folio-org/stripes-components/commit/17f75f1ee0ce8837fb84a81c0f7ee4cab248272a](https://github.com/folio-org/stripes-components/commit/17f75f1ee0ce8837fb84a81c0f7ee4cab248272a)
