On 3-Nov-2003, bad <d.***********@ mervisoft.de> wrote:
i´ve two variables the year and the week (2003 and 5) that means the 5th
week of the year 2003.
now i need the start- and enddate of the 5th week of year 2003.
i hope someone can help me to solve this problem.
$year = 2003;
$week = 4;
// this assumes that the first week of the year starts on a Sunday
$weekoffset = $week-1; // make week offset zero based
$soytime = strtotime("1/1/$year"); // get the timestamp for the 1st day of
the year
$soyoffset = date('w',$soyti me); // get the number of days past sunday
$soydatetime = strtotime("-$soyoffset day",$soytime) ; // get the timestamp
for the sunday before or == to the start date of the year
$soweektime = strtotime("+$we ekoffset week",$soydatet ime); // get the
timestamp for the sunday of the week
$startOfWeek = date('m/d/Y',$soweektime) ; // convert the timestamp to a date
$endOfWeek = date('m/d/Y',strtotime("+ 1 week",$soweekti me)); // add a week
and convert to a date
--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to
ja*********@wil lglen.net (it's reserved for spammers)