Code :
function getFirstDayOfWeek($Week, $Year) { if ($Week > 0) { if (date('W', mktime(0, 0, 0, 01, 01, $Year)) == 1) { $FirstDayOfYearStamp = mktime(0, 0, 0, 01, (01 + (($Week - 1) * 7)), $Year); } else { $FirstDayOfYearStamp = mktime(0, 0, 0, 01, (01 + ($Week * 7)), $Year); } $Shift = 0; // For the years beginning with a sunday if (date('w', $FirstDayOfYearStamp) == 0) { $Shift = 6 * 60 * 60 * 24; } else if (date('w', $FirstDayOfYearStamp) > 1) { $Shift = ((date('w', $FirstDayOfYearStamp) - 1) * 60 * 60 * 24); } return date('Y-m-d', $FirstDayOfYearStamp - $Shift); } // Error return ''; }
|