php - php date_create_from_format 无法正常工作
问题描述
当我使用
<?php
$mnth=date_format(date_create_from_format('m', '2'), 'F');
echo $mnth;
?>
它显示三月而不是二月。我在 4 月、6 月、9 月和 11 月有类似的问题。任何人都对此有想法。请帮我
解决方案
使用 '!m' 作为格式。这 '!' 将所有字段(年、月、日、小时、分钟、秒、分数和时区信息)重置为 Unix 纪元。没有 '!' 所有字段都将设置为当前日期和时间。今天是 2018 年 8 月 31 日,2 月、4 月、6 月、9 月和 11 月没有 31 天。
<?php
$mnth = date_format(date_create_from_format('!m', '2'), 'F');
echo $mnth;
?>
推荐阅读
- xcode - 每当添加断点时 LLDB 就会崩溃
- r - 在 R 中设置边距
- csv - Google Drive API v3 - 在工作表中导入 CSV - 是否可以禁用智能转换?
- reactjs - 有没有办法改变 reactjs 中状态变量的值,即使在页面刷新后它仍然保持变化
- vagrant - PC重新启动后,流浪机器无法启动。它显示端口冲突
- spring - Spring Boot 在 BasicAuthenticationFilter 上抛出 NumberFormatException
- vb.net - 更新 datagridview visualbasic 2010 中的项目
- spring-cloud - @RefreshScope 和 /refresh 不适用于多个实例
- html - CSS - 如何在输入文本旁边制作按钮?
- javascript - 角度服务(如 ChangeDetectorRef)如何获取使用它的组件 ref?