如何在php中使用setlocale函数获取法语的月份名称? [英] How to use setlocale function in php to get month name in french?
本文介绍了如何在php中使用setlocale函数获取法语的月份名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用php代码$formated_date_new = date('M d, Y',strtotime($this_date));
这给了我英文的月份名称.
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");
我想要的o/p是:
13 mars 2019
推荐答案
使用strftime代替日期:
Use strftime instead of date:
setlocale( LC_TIME, "fr_FR" );
$formated_date_new = strftime( "%d %b %Y", strtotime( $this_date ) );
strftime引用:
strftime refernce:
http://php.net/manual/en/function.strftime.php
这篇关于如何在php中使用setlocale函数获取法语的月份名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文