What is the difference between using "o" and "Y" format characters in the date function in PHP?

When using the date function in PHP, the "o" format character represents the ISO-8601 year number, while the "Y" format character represents the four-digit year number. The main difference is that the "o" format character will return the year number based on the ISO-8601 week-numbering year, which may differ from the calendar year in some cases. If you want to ensure you always get the calendar year, it's safer to use the "Y" format character.

// Using "Y" format character to get the four-digit calendar year
$calendar_year = date("Y");

// Using "o" format character to get the ISO-8601 year number
$iso_year = date("o");