What is the recommended way to format a date in PHP from YYYY-MM-DD to DD.MM.YYYY?

To format a date from YYYY-MM-DD to DD.MM.YYYY in PHP, you can use the `DateTime` class to parse the date string and then format it using the `format()` method with the desired format. This allows you to easily convert the date format without having to manually manipulate the string.

$dateString = '2022-01-15';
$date = DateTime::createFromFormat('Y-m-d', $dateString);
$formattedDate = $date->format('d.m.Y');
echo $formattedDate;