To find the current month in PHP, you can use the date
function with the format parameter n
which returns the numeric representation of the month without leading zeros.
main.php27 chars2 lines
This will give you an integer value from 1 to 12 representing the current month. If you want to display the month name instead of the numeric representation, you can use the F
format parameter.
main.php31 chars2 lines
This will give you the full name of the current month. If you want to get the abbreviated month name, you can use the M
format parameter.
main.php31 chars2 lines
These are some of the ways you can find the current month in PHP.
gistlibby LogSnag