Get day from string in spanish PHP

前端 未结 4 916
臣服心动
臣服心动 2020-12-31 07:45

I\'m trying with:

 setlocale(LC_ALL,\"es_ES\");
 $string = \"24/11/2014\";
 $date = DateTime::createFromFormat(\"d/m/Y\", $string);
 echo $date->format(\"         


        
4条回答
  •  自闭症患者
    2020-12-31 08:13

    I use:

    setlocale(LC_ALL, "es_ES", 'Spanish_Spain', 'Spanish');
    echo iconv('ISO-8859-2', 'UTF-8', strftime("%A, %d de %B de %Y", strtotime($row['date'])));
    

    or

    setlocale(LC_ALL,"es_ES@euro","es_ES","esp");
    

    both works. I have to use iconv to avoid strange symbols in accents, and i obtain this result:

    domingo, 09 de octubre de 2016
    

提交回复
热议问题