How to get every 15th and last day of the month in PHP

前端 未结 5 1258
执笔经年
执笔经年 2021-01-13 03:21

I am trying to figure out on how to set my dates to every 15th and end of month only...what i\'m getting so far is only +15 days from my current date.. current date = date t

5条回答
  •  生来不讨喜
    2021-01-13 04:01

    You can use mktime with 0 and 15 as value for the day:

    $a = date("m-d", mktime(0,0,0,$month,0));
    $b = date("m-d", mktime(0,0,0,$month,15));
    

    This will give you the last day of the previous month and the 15. of $month

提交回复
热议问题