php - 如何在 php 中使用 setlocale 函数获取法语月份名称?
问题描述
我正在研究一个 php 代码 $formated_date_new = date('M d, Y',strtotime($this_date));
,它给了我英文月份的名称。
<script>
document.getElementById('title_en').value = "<?php echo $formated_date_new ?>";
</script>
上面的脚本以以下格式返回日期(月份名称为英文):
Mar 13, 2019
为了获得法语月份的名称,我需要集成以下代码,但我不知道该怎么做。
<?php
setlocale(LC_TIME, "fr_FR");
echo strftime(" in French %d.%M.%Y and");
我想要的 o/p 是:
13 mars 2019
解决方案
使用 strftime 代替日期:
setlocale( LC_TIME, "fr_FR" );
$formated_date_new = strftime( "%d %b %Y", strtotime( $this_date ) );
strftime 参考:
推荐阅读
- sql - 使用连接或任何其他方法连接两个查询?
- bash - 如何使用 Iperf3 仅输出 5 个并行连接的平均带宽?
- c# - IIS。是否可以将网站配置为限制连接数 = 1,但是所有新连接都将放在队列中?
- java - 从 Spring Boot 程序调用的 Oracle 存储过程不在数据库中进行任何更改
- javascript - 使用正则表达式验证字符串
- bash - 如何选择 grep 输出的某个部分?
- kubernetes-helm - Helm 不使用 values.yaml 文件
- json - Electron-Packager 什么都不做
- django - Django jinja 值未正确传递到 iframe url(打开街道地图)
- vim - 有没有办法通过按 Escape 来取消 fzf