如何使用PHP将月份的数字转换为月份的名称

如何使用PHP将月份的数字转换为月份的名称

问题描述:

我有一个带有2位数月份数字的变量.是否有一个内置功能,可以让我将其更改为月份名称.我以为date()函数可能会起作用,但这需要完整的时间戳.

I have a variable with a 2 digit month number. Is there a built in function that allows me to change it to the month name. I thought maybe the date() function would work, but that requires a full timestamp.

您可以任意使用 mktime 参数(月份除外),然后使用 date 进行格式化(这可能会给您带来一些地区上的便利).

You can use mktime with arbitrary parameters (exception of month) and then format using date (this might buy you something as far as locales).

 date('M', mktime(0, 0, 0, $month, 1, 2000));