# I18n nice function does not work as it is described in the docs

**URL:** <https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604>\
**Category:** Need Help\
**Tags:** i18n, help\
**Created:** [October 28, 2023, 9:59am UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604 "2023-10-28T09:59:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tri4ngel](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@Tri4ngel](https://discourse.cakephp.org/u/Tri4ngel)\
**Post date:** [October 28, 2023, 9:59am UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/1 "2023-10-28T09:59:30Z")

</div>

Hello,  
i have a problem with formatting FrozenTime values. I want to use the following code snippet  
$startTime = $this-\>start-\>nice($timezoneString, $localeString);

The start atrribute is from type FrozenTime. nice is the function call from the cakephp docs. I have uploaded a picture of the docs.

 ![grafik](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/2/2475b8fb5c4ab8bcceb1bed046dfabdc813495f0.png)

I know that FrozenTime is immutable but my example from above should work i think. I am using the nice format as it is shown in the doc.  
But the function always gives back the following date format: “Oct 28, 2023, 11:54 AM”  
even if I change the locale string for example to german. I tried to debug this problem but i can’t find an answer to the problem.

Would be pretty nice if someone can help me.

I have the php Version 8.1.8 and cakephp Version 4.4.16.

Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [October 28, 2023, 10:47am UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/2 "2023-10-28T10:47:24Z")

</div>

If I do

```auto
$time = new \Cake\I18n\FrozenTime();
var_dump($time->nice('Europe/Vienna', 'en-US'));

```

I get

```auto
Oct 28, 2023, 12:41 PM

```

and with

```auto
$time = new \Cake\I18n\FrozenTime();
var_dump($time->nice('Europe/Vienna', 'de-DE'));

```

I get

```auto
28.10.2023, 12:42

```

which is both what I would expect.

I’d recommend you check your PHP modules via `php -m` and make sure the [intl extension](https://www.php.net/manual/en/book.intl.php) is enabled.

Also you can check the installed ICU version via `php -i | grep ICU` which for me shows these versions:

```auto
ICU version => 73.2
ICU Data version => 73.2
ICU TZData version => 2023c
ICU Unicode version => 15.0

```

---

<div class="post-metadata">

**Author:** ![Tri4ngel](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@Tri4ngel](https://discourse.cakephp.org/u/Tri4ngel)\
**Post date:** [October 30, 2023, 11:20am UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/3 "2023-10-30T11:20:09Z")

</div>

Hello Kevin,

thanks for your answer. Your output is exactly that for what i am looking for. I have checked my php modules. intl is listed if i type in `php -m`. That fits. I checked also my installed ICU Version. It gives back other version than yours.

```auto
ICU version => 71.1
ICU Data version => 71.1
ICU Unicode version => 14.0

```

I have no ICU TZData version like you. Could that be the problem?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [October 30, 2023, 11:32am UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/4 "2023-10-30T11:32:16Z")

</div>

At least in my server I have a package called `tzdata` installed

```auto
root•~» dpkg --list | grep tzdata [12:31:21]
ii tzdata 2023c-5 all time zone and daylight-saving time data

```

Maybe you don’t have that installed?  
But usually it comes as a dependency if PHP intl needs it which it doesn’t seem to…

```auto
root•~» apt depends tzdata [12:31:51]
tzdata
 |Depends: debconf (>= 0.5)
  Depends: <debconf-2.0>
    cdebconf
    debconf

root•~» apt depends php8.2-intl [12:32:47]
php8.2-intl
  Depends: php-common (>= 1:81~)
  Depends: ucf
  Depends: php8.2-common (= 8.2.12-1+0~20231027.35+debian12~1.gbp517c79)
  Depends: libc6 (>= 2.14)
  Depends: libgcc-s1 (>= 3.0)
  Depends: libicu72 (>= 72.1~rc-1~)

```

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [October 30, 2023, 4:40pm UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/5 "2023-10-30T16:40:06Z")

</div>

> [@Tri4ngel](#):
>
> $startTime = $this-\>start-\>nice($timezoneString, $localeString);

Can you chain method calls on an immutable like this?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [October 30, 2023, 5:00pm UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/6 "2023-10-30T17:00:33Z")

</div>

there is no chain method call happening in

```auto
$this->start->nice($timezoneString, $localeString);

```

`$this->start` is just the property inside the entity I would assume just like `$this->created` or `$this->modified`

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [October 30, 2023, 5:23pm UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/7 "2023-10-30T17:23:38Z")

</div>

Thanks, my eyes deceived me

---

<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:** [October 30, 2023, 10:12pm UTC](https://discourse.cakephp.org/t/i18n-nice-function-does-not-work-as-it-is-described-in-the-docs/11604/8 "2023-10-30T22:12:39Z")

</div>

Also, yes, you can very much chain calls on immutables. Each call returns a new object, which the next call then acts on. `$this->start->addMonth()->firstOfMonth()->nice(...)` will give you the nice format for the first day of the month after the start date of the thing.
