How to get a previous year in PHP

How to get a previous year in PHP

In this post we will give you information about How to get a previous year in PHP. Hear we will give you detail about How to get a previous year in PHPAnd how to use it also give you demo for it if it is necessary.

we are going to learn about how to get the previous year in PHP.

Getting the previous year

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.

The 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;

Output:

2020

Hope this code and post will helped you for implement How to get a previous year in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US