In PHP, you can get the name of the day from a date using the date()
function with the “l” format character. Here’s an example:
$dateString = '2023-02-25'; // The date to get the day name from, in YYYY-MM-DD format
$dayName = date('l', strtotime($dateString)); // Get the day name from the date
echo $dayName; // Output: Saturday
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 “l” format character to get the full name of the day of the week. The date()
function formats a Unix timestamp into a string representing a date, using the specified format.
The “l” format character outputs the full name of the day of the week (e.g. “Sunday”, “Monday”, 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.