how to get the number of days of the current month? in PHP

后端 未结 11 1892
悲哀的现实
悲哀的现实 2021-02-12 03:35

i want to check if today is the last day of the month, but i don\'t really know how. i want to write it in php.

can you help?

thanks, Sebastian

11条回答
  •  爱一瞬间的悲伤
    2021-02-12 04:09

    There is probably a more elegant solution than this but you can just use php's date function:

    $maxDays=date('t');
    $currentDayOfMonth=date('j');
    
    if($maxDays == $currentDayOfMonth){
      //Last day of month
    }else{
      //Not last day of the month
    }
    

提交回复
热议问题