3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = "2018-05-07"; $end = "2019-07-04"; $times = 0; // Check if first and last month in the range has a 14th. If(date("d", strtotime($start)) <= 14) $times++; If(date("d", strtotime($end)) >= 14) $times++; // Create an array with months between start and end $months = range(strtotime($start . "+1 month"), strtotime($end . "-1 month"), 86400*30); Var_dump($months); // Add the count of the months $times += count($months); Echo $times;

preferences:
33.42 ms | 407 KiB | 5 Q