Find the date for next 15th using php

2019-09-19 23:39发布

I am trying to find the date when it's next 15th. I came across this Get the date of the next occurrence of the 18th but this shows the today date if its' 18th..I want to see August 18th 20111.

Is there any way to get the next 15th?

regards

标签: php date time
3条回答
再贱就再见
2楼-- · 2019-09-20 00:11

Looking at the link you provided above, I would assume you change the following:

$nextDay = 18;

I'd change that to:

$nextDay = 15;
查看更多
We Are One
3楼-- · 2019-09-20 00:15
if(date('d') >= 15)
    $date = date('Y-m', strtotime('+1 month')).-'.$nextDay
else
    $date = date('Y-m').'-'.$nextDay;
查看更多
叼着烟拽天下
4楼-- · 2019-09-20 00:16
                                   // dynamic typing FTW
$next15th = mktime(0, 0, 0, date('n') + (date('j') >= 15), 15);

echo date('Y-m-d', $next15th);
查看更多
登录 后发表回答