0
你好,我正在嘗試設置我的dateFormat爲FY:jS \ FY,但系統沒有按期望顯示,我預計2015年9月7日星期一,但它給出星期一7 \ 2015關注Yii2日期時間格式錯誤
你好,我正在嘗試設置我的dateFormat爲FY:jS \ FY,但系統沒有按期望顯示,我預計2015年9月7日星期一,但它給出星期一7 \ 2015關注Yii2日期時間格式錯誤
格式化使用此模式語法
http://stuff.cebe.cc/yii2docs/yii-i18n-formatter.html#$dateFormat-detail
http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax
您的格式將是這樣的:
Yii::$app->formatter->asDate(strtotime($model->attribute), $format = "EEEE dd 'of' LLLL yyyy KK:m:s a")
不知道如何添加模式中的「st」,「nd」,「rd」部分。從上面給出的模式中,這仍然是缺失的。 (你可以查找自己)
但你也可以只使用普通的PHP日期函數,如:
echo date("l jS \of F Y h:i:s A",strtotime($model->attribute));
它可以是你的PHP缺少了'intl'擴展? – Beowulfenator