How to calculate the number of days from the current moment to a certain point in the next month. I tried this and returns 0 for some reason, the month doesn’t take into account whatever number there is.

function calcDifference($params){ $datetime1 = new DateTime('2016-07-11'); $datetime2 = new DateTime('2016-08-11'); $interval = $datetime1->diff($datetime2); echo $interval->format('%d'); } 

    1 answer 1

    Try

     echo $interval->format('%a'); 

    This command will display the total number of whole days in the interval. The team in your question displays only the number of days not covered by the month.

    • That is necessary, thanks! - quaresma89