Skip to content
PHP Logo

How can PHP be used to convert English dates to German dates in a web application?

To convert English dates to German dates in a web application using PHP, you can use the `setlocale` function to set the locale to German and then use the `strftime` function to format the date accordingly.

php
// Set the locale to German
setlocale(LC_TIME, 'de_DE');

// Convert English date to German date
$englishDate = '2022-01-15';
$germanDate = strftime('%d. %B %Y', strtotime($englishDate));

echo $germanDate; // Output: 15. Januar 2022