How to Get Previous Year From Date In Codeigniter?

Codeigniter

Nicesnippets

1424

19-01-2021


Hi Guys,

In this example,I will learn you how to get previous year from date in codeigniter.you can easy and simply get previous year from date in codeigniter.

we will show you how to get previous year from date in codeigniter.if you want to get previous year from date in codeigniter then you can use bellow example.

Example:


public function index()

{

$date = "2020-01-11";

$newdate = date("Y-m-d",strtotime ( '-1 year' , strtotime ( $date ) )) ;

echo $newdate;

}

Output:

2019-01-11

It will help you...