将日期增加一个月 [英] increment date by one month
本文介绍了将日期增加一个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有以下格式的日期:2010-12-11(年-周一-日)
Let's say I have a date in the following format: 2010-12-11 (year-mon-day)
对于 PHP,我想将日期增加一个月,并且我希望年份在必要时自动增加(即从 2012 年 12 月增加到 2013 年 1 月).
With PHP, I want to increment the date by one month, and I want the year to be automatically incremented, if necessary (i.e. incrementing from December 2012 to January 2013).
问候.
推荐答案
$time = strtotime("2010.12.11");
$final = date("Y-m-d", strtotime("+1 month", $time));
// Finally you will have the date you're looking for.
这篇关于将日期增加一个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文