php获取指定日期的前一天,前一月,前一年日期
前一天的日期为:
date(“Y-m-d”,strtotime("-1 days",strtotime(‘2014-07-01’)))
前一月的日期为:
date(“Y-m-d”,strtotime("-1 months",strtotime(‘2014-07-01’)))
前一年的日期为:
date(“Y-m-d”,strtotime("-1 years",strtotime(‘2014-07-01’)))
后一天的日期为:
date(“Y-m-d”,strtotime("+1 days",strtotime(‘2014-07-01’)))
后一月的日期为:
date(“Y-m-d”,strtotime("+1 months",strtotime(‘2014-07-01’)))
后一年的日期为:
date(“Y-m-d”,strtotime("+1 years",strtotime(‘2014-07-01’)))
如果不是1,就把+1或者-1换成+n或者-n就可以了。
本文介绍如何使用PHP的date()和strtotime()函数来获取指定日期的前一天、前一月、前一年以及后一天、后一月、后一年的具体日期。通过简单的代码示例,读者可以快速掌握日期计算的方法。
1432

被折叠的 条评论
为什么被折叠?



