问题
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