获取下一次发生的日期18日 [英] Get the date of the next occurrence of the 18th
本文介绍了获取下一次发生的日期18日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,所以我需要使用PHP来获取下一次发生的第18个日期。
Okay, so I need to use PHP to obtain the date of the next occurrence of the 18th.
例如,假设我在12月运行了我的脚本。我将需要一些能够吐出2012-01-18的代码。如果是2011年4月9日,我将需要代码吐出2011-04-18。有意义吗?
For example, let's say I ran my script on Dec. 28th, 2011. I would need some code that would be able to spit out 2012-01-18. If it were April 9th, 2011, I would need the code to spit out 2011-04-18. Make sense?
任何想法?
推荐答案
这应该给你下一次发生的第18个
This should give you the next occurrence of the 18th
$nextDay = 18;
$nextDate = (date('d') > $nextDay) ? date('Y-m', strtotime('+1 month')).-'.$nextDay : date('Y-m').'-'.$nextDay;
这篇关于获取下一次发生的日期18日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文