How can PHP be used to convert dates from a "dd.mm.yyyy" format to a "yyyy-mm-dd" format?

To convert dates from a "dd.mm.yyyy" format to a "yyyy-mm-dd" format in PHP, you can use the `DateTime` class. First, you need to create a `DateTime` object from the input date string using `createFromFormat()`, and then format the date using the `format()` method with the desired format.

$inputDate = '25.12.2021';
$dateObj = DateTime::createFromFormat('d.m.Y', $inputDate);
$outputDate = $dateObj->format('Y-m-d');

echo $outputDate; // Output: 2021-12-25