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