Reputation: 361
I'm having a problem with the yii2 date formatter, it doesn't use the locale that I have set. The global language is set to de-DE, it seems to take effect everywhere except for the date formatter. I've tryed to set the formatter locale in the config file like this:
'formatter' => [
'dateFormat' => 'dd.MM.yyyy',
'decimalSeparator' => ',',
'thousandSeparator' => ' ',
'currencyCode' => 'EUR',
'locale'=>'de_DE'
],
and also directly before using the formatter in code:
Yii::$app->formatter->locale = 'de-DE';
echo Yii::$app->formatter->asDatetime('2014-01-01');
but it formats the date to Jan 1, 2014 10:04:36 AM. Any ideas?
Upvotes: 2
Views: 1961
Reputation: 11
possible reason: check and make sure that php-intl extension is installed.
see: https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n#parameter-formatting
Upvotes: 0
Reputation: 2267
The param dateFormat
only has effect for asDate()
. For asDatetime()
set datetimeFormat
.
Upvotes: 1