PHP中将数字转换为月份名称的方法
要将数字转换为PHP中的月份名称,代码如下-
示例
<?php
$date = "2019-11-11";
echo "Displaying date...\n";
echo "Date = $date";
$month_name = date("F", mktime(0, 0, 0, 11, 10));
echo "\nMonth = ".$month_name."\n";
echo "\nDisplaying updated date...\n";
echo date('Y-m-d', strtotime($date. ' + 20 days'));
?>输出结果
这将产生以下输出-
Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01
示例
现在让我们来看另一个示例-
<?php
$date = "2019-11-11";
echo "Displaying date...\n";
echo "Date = $date";
$month_name = date("F", mktime(0, 0, 0, 11, 10));
echo "\nMonth = ".$month_name."\n";
echo "\nDisplaying updated date...\n";
echo date('Y-m-d', strtotime($date. ' + 20 days'));
$val = DateTime::createFromFormat('!m', 12);
$month_name2 = $val->format('F');
echo "\nMonth = ".$month_name2."\n";
?>输出结果
这将产生以下输出-
Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01 Month = December
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短