php - 如何在php中用法语硬编码月份名称?
问题描述
我正在研究下面的 php/javascript 代码,它以法语返回月份名称,但它与我们使用的法语单词不匹配。
<script>
document.getElementById('title_fr').value = "<?php setlocale(LC_TIME, "frc"); echo strftime("%d %b %Y", strtotime( $this_date )); ?>";
</script>
上面的脚本以法语返回月份名称,这与我们的法语月份名称集不匹配。
mars
avr.
mai
juin
juil.
août
sept.
oct.
nov.
déc.
以下是我们遵循的法语月份名称集:
janvier
février
mars
avril
mai
juin
juillet
août
septembre
octobre
novembre
décembre
问题陈述:
我想知道我需要在上面的脚本中进行哪些更改,以便它返回我正在关注的法语月份名称。
我相信我需要使用法语月份名称创建一个数组,如下所示。
const monthNamesFr = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
解决方案
因为这似乎在起作用(来自评论部分)。无需将日期硬编码在数组中,只需从strftime()
函数中请求整月:
setlocale(LC_TIME, "frc"); echo strftime("%d %B %Y", strtotime( $this_date ));
推荐阅读
- python - 超出表中每一列的范围计数
- amazon-web-services - S3 依赖未打包
- python - 在后台运行 Python 脚本
- python - Spyder 4:代码分析——约定、重构、警告和错误
- html - 多选下拉背景更改
- java - 如何在 Spring-Boot 中捕获属性的 NumberFormatException?
- python - 我面临一个错误,服务器无法在 Python TCP 套接字中向客户端发送确认消息
- ios - Swift 如何在协议中符合不同的关联类型
- reactjs - 如何在 PWA 中长时间离线后保持用户登录?
- typescript - TypeError:无法读取未定义的属性“替换”-不确定它的来源,因为我不在回购中使用替换