CakePHP 3.5.13. I am getting some records from MySQL which are stored as DATE
fields. For example: 2018-07-30
I want Cake to output the dates in that format. However, it is converting them to British dd/mm/yyyy
format. So the example above comes out as 30/07/2018
in my template files.
The data returned from the database looks like this:
'date' => object(Cake\I18n\FrozenDate) {
'time' => '2018-07-30T00:00:00+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
In my config/app.php
the locale is set to en_GB
:
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_GB'),
I assume this is the reason it's displaying all of the dates in this way.
All I am doing in the template is displaying the data returned from the database - no conversion is occurring within my code:
// In a controller
$RevisionSubstances = TableRegistry::get('RevisionSubstances');
$revision_comments = $RevisionSubstances->find('all')->toArray();
debug($revision_comments); // format is '2018-07-30T00:00:00+00:00'
// In the template
echo $revision_comments['date']; // format is '30/07/2018'
How do I get the dates to be output in yyyy-mm-dd
format?
I had a look at these resources but can't see the answer: