Reputation: 6032
I want to get the year of the previous month.
For example in July 2012
I want result 2012
.
But in January 2013
I want result 2012
and in Feb 2013
I want result 2013
I have searched and found this How to get previous month and year relative to today, using strtotime and date?
It uses date_create
function (i.e. DateTime Class). But I want a solution without using it. i.e. by using simple date()
function
Upvotes: 1
Views: 142
Reputation: 7634
<?php
echo date('Y', strtotime('-1 month'));
Should work as expected.
Upvotes: 4