简体   繁体   English

获得上一个月和下个月的年份

[英]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. 在我的日历中,我需要将当前年份与上一年和下一年的年份进行比较,以确定月份是否需要重置为1月,并且年份递增/递减。 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. 提前谢谢 - 坦纳。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM