Caveat: though still supported by web browsers, the getYear() method is now deprecated: don't use it whenever possible, we'll show you how to get any format you want with getFullYear().
getYear() vs. getFullYear(): getYear() returns the current year minus 1900, mostly useful for dates up to 1999 (in 2-digit format); getFullYear() returns the four-digit year.
var cal = new Date(); // Automatically set to "today" in user's local time
alert( cal.getFullYear() ); // 2024
alert( (new Date()).getFullYear() );
var year = (new Date()).getFullYear();
alert( year.toString().substring(2) ); // 24
echo date('Y') . '<br>'; // Uppercase 'Y' as argument for a four-digit year
echo date('y') . '<br>'; // Lowercase 'y' for a two-digit year