如何在PHP中检查这一天是该月的最后一天?

DS9*_*DS9 2 php date

我之前的问题:how-to-find-current-day-no-in-month-in-php

现在我面临另一个问题。假设我知道这monday4th monday of the current month.现在如何检查this monday is also the last monday of the current month

exa:1 
date: 27-01-2014
Run Code Online (Sandbox Code Playgroud)

使用下面的代码,我可以获得一天的名称和数字:

day: monday   
day no :4th
Run Code Online (Sandbox Code Playgroud)

这是一月的第四个星期一,也是一月的最后一个星期一。如何检查?

exa:2  
date: 20-01-2014   
day: monday   
day no :3rd
Run Code Online (Sandbox Code Playgroud)

这里this monday is 3rd monday of january but not last monday of january.

那么,简而言之,当我得到一个天数时,如何检查该天数是否是最后一个呢?

code:

$t=date('d-m-Y');
$dayName = strtolower(date("D",strtotime($t)));
$dayNum = strtolower(date("d",strtotime($t)));
$dayno = floor(($dayNum - 1) / 7) + 1
Run Code Online (Sandbox Code Playgroud)

小智 6

检查今天是否是本月最后一天的最快方法我建议如下

 if(date('t') == date('d')){
    echo 'Last day of the month.';
}
Run Code Online (Sandbox Code Playgroud)

这会将当天与当月的天数进行比较。