如何根据区域设置格式化日期? [英] How to format dates based on locale?

查看:171
本文介绍了如何根据区域设置格式化日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模板中,我显示特定日期的日期和月份:

In a template I display the day and month of a specific date :

<div class="jour"><?php echo date('d',strtotime($content->getCreatedAt())) ?></div>
<div class="mois"><?php echo date('M',strtotime($content->getCreatedAt())) ?></div>

这个工作正常,问题是月名是英文。我在哪里指定我想要在另一个地区的月份名称,例如法语?

This works fine, problem is the month name is in English. Where do I specify that I want the month names in another locale, French for instance ?

推荐答案

Symfony有一个 format_date 在i18n知道的日期助手之间的帮手。这些格式不幸被记录在案,看到这个链接,以提示他们。

Symfony has a format_date helper among the Date helpers that is i18n-aware. The formats are unfortunately badly documented, see this link for a hint on them.

这篇关于如何根据区域设置格式化日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆