Tanner Ottinger
Tanner Ottinger

Reputation: 3060

Get year of previous and next months

In my calendar, I need to compare the current year to the years of previous and next years to find out if the month needs to reset back to January, and the year incremented/decremented. I already have this to get the next & previous months:

$prev_month = date('F',strtotime("last month"));
$next_month = date('F',strtotime("next month"));

Does anybody have any idea how to do this? Thanks in advance - Tanner.

Upvotes: 3

Views: 375

Answers (1)

ADW
ADW

Reputation: 4070

$next_month_y = date('Y',strtotime("last month"));
$prev_month_y = date('Y',strtotime("next month"));

Upvotes: 5

Related Questions