How to use setlocale function in php to get month name in french?

风格不统一 提交于 2019-12-11 17:19:08

问题


I am working on a php code $formated_date_new = date('M d, Y',strtotime($this_date)); which gives me the month name in english.

<script>
       document.getElementById('title_en').value = "<?php echo $formated_date_new ?>";
</script>

The above script returns the date in the following format (with month name in english) :

Mar 13, 2019 

For getting the month name in french, I need to integrate the following code but I am not sure how to do it.

<?php
setlocale(LC_TIME, "fr_FR");
echo strftime(" in French %d.%M.%Y and");


The o/p which I want is:

13 mars 2019

回答1:


Use strftime instead of date:

setlocale( LC_TIME, "fr_FR" );
$formated_date_new = strftime( "%d %b %Y", strtotime( $this_date ) );

strftime refernce:

http://php.net/manual/en/function.strftime.php




回答2:


$formatted_date_new = strftime(" in French %d.%M.%Y and");

I am not sure to understand your problem



来源:https://stackoverflow.com/questions/55151809/how-to-use-setlocale-function-in-php-to-get-month-name-in-french

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!