Hi all.
I need to change the default date formats for italian, french and german languages.
Is there any way to set it in bootstrap.php / application.php?
I wish to avoid dozens of “ifs” in my templates.
I’m on Cake 3.7
I tried but without success
Show what you have tried, and explain what’s not working about it.
I followed the steps described in this chapter
I added this code to my bootstrap.php, just to test if it will work
Time::setToStringFormat('HH ss yyyy');
FrozenTime::setToStringFormat('HH ss yyyy');
Date::setToStringFormat('HH ss yyyy');
FrozenDate::setToStringFormat('HH ss yyyy');
Unfortunately it didn’t
What does the code you’re using to actually output values look like? You are still not showing nearly enough of what you’re doing for us to be able to really help.
<td class="date"><?= $order->created_on->nice(); ?></td>
created_on is a ‘date’ field, mapped to a FrozenTime object by Cake
If you look again at the link I gave, it seems that the “string format” is used by the i18nFormat
function. The nice
function uses the default locale, which you’re not setting in the code you’ve shown.