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

后端 未结 11 1879
悲哀的现实
悲哀的现实 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 03:58

    In order to get no. of days in month you can use either

    date('t')
    

    OR

    cal_days_in_month(CAL_GREGORIAN, 8, 2003)
    

    And if you wish to check if today is the last day of month us can use

    if(date('d')==date('d',strtotime('last day of month'))){
    //your code
    }
    

    strtotime offers many great features so check them out first

提交回复
热议问题