取得上一个月和下个月的年份 [英] Get year of previous and next months

查看:369
本文介绍了取得上一个月和下个月的年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的日程表中,我需要比较今年和以前年份的年份,以了解该月份是否需要重新设定为1月份,并且年度递增/递减。我已经有了这个获得下一个&前几个月:

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"));

有没有人知道如何做到这一点?感谢提前 - Tanner。

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"));

这篇关于取得上一个月和下个月的年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆