How to find first day of the next month and remaining days till this date with PHP

前端 未结 15 815
难免孤独
难免孤独 2020-12-08 14:36

How can I find first day of the next month and the remaining days till this day from the present day?

Thank you

15条回答
  •  情书的邮戳
    2020-12-08 15:03

    Create a timestamp for 00:00 on the first day of next month:

    $firstDayNextMonth = strtotime('first day of next month');
    

    The number of days til that date is the number of seconds between now and then divided by (24 * 60 * 60).

    $daysTilNextMonth = ($firstDayNextMonth - time()) / (24 * 3600);
    

提交回复
热议问题