List days of the current week with PHP

0

I have to make a calendar with PHP and it's practically ready, the problem is only that for example, today ( 07/28/2016 ) the calendar week starts at 01/08/2016 and the right should be 25/07/2016 by 29/07/2016 (Monday through Friday).

>

I have the function below:

<?php
public function DataSemana($semana = 1){

        $c = time() + 60*60*24*5*$semana;
        $date = date('Y-m-d', $c);
        $dayofweek = date('w', strtotime($date));
        $result    = strtotime((0-$dayofweek+1).' day', strtotime($date));

        $primeira_data = date('Y-m-d', $result);
        $segunda_data = date('Y-m-d', $result+(60*60*24*5));

        $inicio = new DateTime($primeira_data);
        $fim = new DateTime($segunda_data);

        //sequencia aritmetica com razao igual a 1 dia
        $intervalo = new DateInterval('P1D');

        $datas = new DatePeriod($inicio, $intervalo, $fim);

        return $datas;
    }
?>
    
asked by anonymous 28.07.2016 / 19:05

0 answers