If you want to apply it everywhere in the cake app, you could do this in your AppController:
<?php
namespace App\Controller;
use Cake\Controller\Controller;
use Cake\I18n\FrozenDate;
use Cake\I18n\FrozenTime;
class AppController extends Controller {
public function initialize(): void {
parent::initialize();
// set date and time format
FrozenDate::setToStringFormat('dd.MM.yyyy');
FrozenTime::setToStringFormat('dd.MM.yyyy, HH:mm');
// load components
$this->loadComponent('Flash');
// ..
}
...
}
The CLI is a good point @KevinPfeifer, thank you for the hint.
I tried to define this settings in the bootstrap and saw, that some things with Date and Time have changed in version 5.
So to define it in the bootstrap.php, the following is needed:
// set date and time format
Cake\I18n\Date::setToStringFormat('dd.MM.yyyy');
Cake\I18n\DateTime::setToStringFormat('dd.MM.yyyy HH:mm');