Date and time localized format

All the examples I found give :
$time->i18nFormat(‘yyyy-MM-dd HH:mm:ss’);

But what if I want :
name_of_the_day name_of_the_month year and no time ?
in localized format, of course ?

You learn about what the format string means.

Although all dates are formatted ‘yyyy-mm-dd’
example 2020-11-12
$date->i18nFormat(‘EEE d MMM yyyy’);
never returns the expected result.
returns “fri 11 dec 2020”
(I de-localized results in my example)
expected result should be : thu 12 nov 2020

You say “dates are formatted yyyy-mm-dd”. They are formatted that way where? How do you know that they are formatted that way? What does debug($date) give you?

They are formatted this way in the event_date column of the sql database.
sql type = date

I have been doing this for a while :
$current_date = $date->i18nFormat([\IntlDateFormatter::FULL, \IntlDateFormatter::SHORT]);
$formatted_date = substr($current_date, 0, -6);

But this is not what should be done.

Debug :
object(Cake\I18n\FrozenDate) {

'time' => '2020-11-12T00:00:00+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false

}

Another problem (and this is a bug for me) :
I have a column named “event_start”. It’s sql type is “time”.
But when I echo it, it renders today’s_date + saved_time.
ex : if the content of the field is “18:30”, the result is 10/11/2020 18:30.
I have multiple time columns but I just can’t read them simply.

This is definitely not a piece of cake.
Time should be a time, not a date.

Welcome to that party. :slight_smile:

That solved the problem.
Thank you for this.