3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = new \DateTime('2017-07-16'); $firstDayOfMonth = new \DateTime($input->format('Y-m-01')); $order = (int)($input->format('n') / 7) + 1; if (($input->format('N') % 7) <= ($firstDayOfMonth->format('N') % 7)) $order++; var_dump($input->format('l')); var_dump($order);

preferences:
51.36 ms | 402 KiB | 5 Q