Link to home
Start Free TrialLog in
Avatar of revo1059
revo1059Flag for United States of America

asked on

Get the friday of a given week number

Hello

I need a way to find the friday for a week number in php.  eg date("W") reports the week number of the current date.  I need a way to take week 14 and tell what day friday would be for that week

I am using php 4 and mysql 5
ASKER CERTIFIED SOLUTION
Avatar of star_trek
star_trek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of revo1059

ASKER

star_trek,

I tried your code, and the page just displays blank.  
this is my exact code


<?php
function getFriday($wk,$yr) {
    $wk = $wk-1;
    $stday = strtotime($wk.' week',mktime(0,0,0,1,1,$yr));
    $wk_num = date("w",$stday);
     $add_day = (5-$wk_num);
    $friday_date = date("Y-m-d",mktime(0,0,0,date("m",$stday),date("d",$stday)+$add_day,date("Y",$stday)));
 
   return $friday_date;



}
getFriday(22,2006);

?>
Avatar of star_trek
star_trek


when you call the function, echo it browser as

echo getFriday(22,2006);
I am what you would call a noob, that worked great.  Thank you