如何从PHP中的一个数字获取月份名称? [英] How to get the month name from a number in PHP?

查看:87
本文介绍了如何从PHP中的一个数字获取月份名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含月份号的变量。如何从这个值得到月份的名字?



我知道我可以为 $ month_num =>定义一个数组$ month_name ,但是我想知道PHP中是否有时间函数可以执行此操作,而不需要数组?

解决方案

  date(F,mktime(0,0,0,$ monthnumber,1,2011)); 


I have a variable containing a month number. How can I get the name of the month from this value?

I know I could define an array for $month_num => $month_name, but I want to know if there is a time function in PHP that can do this, without the need for an array?

解决方案

date("F",mktime(0,0,0,$monthnumber,1,2011));

这篇关于如何从PHP中的一个数字获取月份名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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