Convert month number to month short name

后端 未结 6 796
无人及你
无人及你 2020-12-11 16:26

I have a variable with the following value

$month = 201002; 

the first 4 numbers represent the year, and the last 2 numbers represent the m

6条回答
  •  借酒劲吻你
    2020-12-11 17:03

    You can use the DateTime Class to get a Date data structure using date string and format. Then get a date string with any format like this:

    $month = 201002; 
    $date = DateTime::createFromFormat('Yd', $month);  
    $monthName = $date->format('M'); // will get Month name
    

提交回复
热议问题