Gyuzal
Gyuzal

Reputation: 1591

Php date_format localized month names, Yii2

I'm new to php and Yii2, and would appreciate any advise.

My website supports 2 languages: English and Mongolian. I am not sure how to localize month names for Mongolian language, using:

date_format(new DateTime($model->start_date), 'd F Y')

Is it a proper way to have an array of Mongolian month names, and then create datetime and place a proper name? Or is there any MN libraries to include to standard php localization?

Thanks a lot.

Upvotes: 1

Views: 1841

Answers (1)

GAMITG
GAMITG

Reputation: 3818

You can try this,

\Yii::$app->formatter->locale = 'mn-CN'; //language code like for english --> en-Us
\Yii::$app->formatter->asDateTime($model->start_date, 'php:d F Y');

or use strftime

Upvotes: 4

Related Questions