In this tutorial, we are going to learn about how to get the previous year in PHP.
To get the previous year in PHP. first, we need to access the current year using the built-in
date("Y") function then we need to subtract it with minus 1.
date("Y")function returns the current year in four-digit(2021) string format according to the user’s local time.
Here is an example:
$currentYear = date("Y"); $previousYear = $currentYear-1; echo $previousYear;