将月份编号转换为月份简称

将月份编号转换为月份简称

问题描述:

我有一个具有以下值的变量

I have a variable with the following value

$month = 201002; 

前4个数字表示年份,后2个数字表示月份.我需要获取月份字符串名称中的最后2个数字,例如. 2月

the first 4 numbers represent the year, and the last 2 numbers represent the month. I need to get the last 2 numbers in the month string name eg. Feb

我的代码如下

<?php echo date('M',substr($month,4,6)); ?>

我可以去获取月份名称

追加"01",strtotime将能够解析字符串:

Append "01" and strtotime will be able to parse the string :

echo date('M', strtotime($month . '01'));