Suppose you want to retrieve or get current year in PHP, you can use the following method to accomplish this.
<?php
// PHP program to get the current year
$year = date("Y");
// Display the year
echo "current year is " . $year;
?>
Notice that we use date()
function with PHP and supply the parameter with Y
as argument. Y
will be automatically treated as Year.
Source: PHP - Date