How can PHP be used to output weekday names in different languages, such as German?

To output weekday names in different languages in PHP, you can use the setlocale() function to set the desired language for the script. Then, you can use the strftime() function to format the date with the '%A' specifier, which will return the full weekday name in the specified language.

setlocale(LC_TIME, 'de_DE'); // Set the locale to German
$weekday = strftime('%A'); // Get the full weekday name in German
echo $weekday; // Output the weekday name in German