它在本地服务器上正常工作,但是当我将其上传到共享主机时,它不显示相对日期,而是显示原始字符串。
代码:
Yii::$app->formatter->asRelativeTime($timestamp, 'now');
本地主机:
in 6 days
共享主机:
in {delta, plural, =1{a day} other{# days}}
区域设置已设置并且时间戳正在传递。国际扩展已启用。其他格式化程序功能(即 asDate)工作正常。
最佳答案
我猜这是因为 PHP intl 扩展的 ICU 库过时了。 我的是4.2.1,而yii2 requires at least ICU version 49 to be able to use all the features ,其中可能包括 asRelativeTime()。
不能肯定地说,因为我无法在我的托管计划上更新它。
关于Yii2 格式化程序relativeTime() 在共享主机上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30137267/