Search code examples
phpdatesymfony1localesetlocale

How to format dates based on locale?


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 ?


Solution

  • 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.