- var_dump: documentation ( source)
<?php
$input = new \DateTime('2017-07-17');
$firstDayOfMonth = new \DateTime($input->format('Y-m-01'));
$order = (int)(($input->format('j') - 1) / 7) + 1;
if (($input->format('N') % 7) > ($firstDayOfMonth->format('N') % 7))
$order++;
var_dump($input->format('Y-m-d: ').$order.'. '.$input->format('l'));