In PHP, you can use the date() function to determine which month this month is. This function can format the current date and convert it into a string or number representing the month. The syntax "date(" format Character ")"; when the format character is "F" or "M", the English word representing the month can be output, and if it is "m" or "n", the number representing the month can be output.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, you can use the date() function to determine which month this month is.
The date() function formats the timestamp into a more readable date and time.
Use the date() function to format the current date and convert it into a string or number representing the month.
date("格式字符")
Format characters can be the following 4 types:
##F | month, complete text Format, such as January or MarchJanuary to December | |
Numerical month, with leading zeros | 01 | to 12 |
Three-letter month abbreviation | Jan | to Dec |
Numerical month, without leading zeros | 1 | to12 |
<?php header("content-type:text/html;charset=utf-8"); echo "本月的月份为:".date("F")."<br>"; echo "本月的月份为:".date("M")."<br>"; echo "本月的月份为:".date("m")."<br>"; echo "本月的月份为:".date("n")."<br>"; ?>
Look at the calendar and compare it to see if it is correct
ok, that’s right.
Recommended learning: "PHP Video Tutorial
"The above is the detailed content of PHP determines which month this month is. For more information, please follow other related articles on the PHP Chinese website!