我想使用 CakePHP Helper "time" 和他的方法 niceShort 将日期转换成一个漂亮的、易于阅读的日期。我想使用本地化版本(在我的情况下:“德语”)而不是英语默认转换,但我不知道在哪里设置它。如何本地化此方法?
echo $time->niceShort($comment['created']);
我想使用 CakePHP Helper "time" 和他的方法 niceShort 将日期转换成一个漂亮的、易于阅读的日期。我想使用本地化版本(在我的情况下:“德语”)而不是英语默认转换,但我不知道在哪里设置它。如何本地化此方法?
echo $time->niceShort($comment['created']);
我认为 cake 不能很好地处理日期本地化,您可能需要使用 $time->format() 请参阅http://cakeqs.org/eng/questions/view/localizing_time_helper和这张票http://cakephp.lighthouseapp。 com/projects/42648/tickets/638-time-helper-i18n
如果您可以成功设置本地化参数,则niceShort
找到正确的月/日名称。
关于CakePHP 文档更改这些:
$this->Session->write('Config.language', 'ger')
Configure::write('Config.language', 'ger');
setlocale(LC_TIME, 'de_DE.utf8','de_DE','de_DE','deu_deu');