如何使用PHP将月份的数字转换为月份的名称 [英] How do I convert numeric month number to name of month using PHP

查看:160
本文介绍了如何使用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));

这篇关于如何使用PHP将月份的数字转换为月份的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆