What is the best way to determine the year of a specific date in PHP?

To determine the year of a specific date in PHP, you can use the date() function along with the 'Y' format character, which represents the year in a four-digit format. This function allows you to extract the year from a given date string or timestamp.

$date = '2022-09-15';
$year = date('Y', strtotime($date));
echo $year; // Output: 2022