Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change month name to french

I have this code:

<?php 
  echo "'".$sgps_newsletter->getEmail()."' demande en ".date('d.M.Y', strtotime($sgps_newsletter->getCreatedAt())) 
?> 

but the month name is appering in english. What can I do to show it in french? I've change the settings.yml default culture to french, but nothing happens.

like image 204
Eva Dias Avatar asked Sep 05 '11 15:09

Eva Dias


1 Answers

A 2022 response:

strftime function has been deprecated since PHP 8.1 (and maybe will be removed on PHP 9)

Try to use this instead:

    $ts = new \DateTime();
    $formatter = new \IntlDateFormatter('fr_FR', \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM);
    $formatter->setPattern('d MMM Y');

    echo $formatter->format($ts);
like image 79
Houssem ZITOUN Avatar answered Oct 26 '22 13:10

Houssem ZITOUN