[Solved] get week number and day from date


$input = new \DateTime('2017-07-17');
$firstDayOfMonth = new \DateTime($input->format('Y-m-01'));
$order = (int)(($input->format('j') - 1) / 7) + 1;

function ordinal($number) {
    $ends = array('th','st','nd','rd','th','th','th','th','th','th');
    if ((($number % 100) >= 11) && (($number%100) <= 13))
        return $number. 'th';
    else
        return $number. $ends[$number % 10];
}

echo ordinal($order).' '.$input->format('l');

You can tinker with the code at https://3v4l.org/dg5Xa

2

solved get week number and day from date