In PHP, you can get the name of the month from a date using the date()
function with the “F” format character. Here’s an example:
$dateString = '2023-02-25'; // The date to get the month name from, in YYYY-MM-DD format
$monthName = date('F', strtotime($dateString)); // Get the month name from the date
echo $monthName; // Output: February
In this example, we first convert the date string to a Unix timestamp using the strtotime()
function. We then use the date()
function with the “F” format character to get the full name of the month. The date()
function formats a Unix timestamp into a string representing a date, using the specified format.
The “F” format character outputs the full name of the month (e.g. “January”, “February”, etc.). If you want to output a different format, you can use other format characters. The full list of format characters is available in the PHP documentation for the date()
function.