开发者

Get the date of the next occurrence of the 18th

开发者 https://www.devze.com 2023-01-17 18:20 出处:网络
Okay, so I need to use PHP to obtain the date of the next occurrence of the 18th. 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 201

Okay, so I need to use PHP to obtain the date of the next occurrence of the 18th.

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-开发者_JAVA技巧01-18. If it were April 9th, 2011, I would need the code to spit out 2011-04-18. Make sense?

Any ideas?


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号