What potential pitfalls can arise when using the strtotime function to determine the year from a date string in PHP?

Using the strtotime function to determine the year from a date string in PHP can lead to unexpected results if the date format is not recognized by the function or if the date string is ambiguous. To avoid potential pitfalls, it is recommended to use the DateTime class in PHP, which provides more flexibility and control over date and time operations.

$dateString = "2022-01-15";
$date = new DateTime($dateString);
$year = $date->format('Y');
echo $year;