Tag Archives: set

CakePhp3 – Date Formating and Timezone

23666Quite simply this is a pain to set right, as it seems to default to the american time zone despite several efforts to configure it to european time in both Cakephp3 and the Php.ini file.

But you can display the needed time format as follows in your view action;

Below the field “created” is a date field in a MySQL Database.

echo $order->created->i18nFormat('dd-MMMM-YYYY HH:mm');

Edit;

To set the timezone of your application you need to go to the config/app.php

Change below as follows;

'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
to
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_IE'),

This wont change the default display of dates but will set the dates to be displayed in the locale you desire.

edit;

MORE here