I built this function in my class:
class CalenderWeekHelper {
public static function getCalenderWeek($year = 2016)
{
for ($i=1; $i <= 52; $i++)
{
$from = date("d.m.Y", strtotime("{$year}-W{$i}-1")); //Returns the date of monday in week
$to = date("d.m.Y", strtotime("{$year}-W{$i}-7")); //Returns the date of sunday in week
$weekArray[$i] = array('start' => $from, 'end' => $to);
}
return $weekArray;
}
}
And call it like this:
$kw = CalenderWeekHelper::getCalenderWeek(2015);
echo $kw[1]['start']
But it still echos me following:
01.01.1970
I just want to loop trough all calender weeks, anyone know how to solve this?