PHP:date函数获取当前日期的月份 [英] PHP: date function to get month of the current date
问题描述
我希望能够找出当前日期变量的月份。我是vb.net的前任者,而方法只是 date.Month
。
I want to be able to figure out the month of the current date variable. I'm ex vb.net and the way to do it there is just date.Month
. How do I do this in PHP?
谢谢,
Jonesy
我使用了 date_format($ date, m); // 01,02..12
这就是我想要的,现在的问题是,由于 $ monthnumber = 01
变成 1
This is what I wanted, question now is how do I compare this to an int since $monthnumber = 01
just becomes 1
推荐答案
date('m')
或 date('n')
或 date( 'F')
...
更新
m 一个月的数字表示,前导零 01到12
m Numeric representation of a month, with leading zeros 01 through 12
n 的数字表示一个月,没有前导零 1到12
n Numeric representation of a month, without leading zeros 1 through 12
F 一个月的字母表示形式一月到十二月
F Alphabetic representation of a month January through December
...。请参阅文档链接以获取更多选项。
....see the docs link for even more options.
这篇关于PHP:date函数获取当前日期的月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!