navjak Posted May 23, 2007 Share Posted May 23, 2007 Hi Freaks, I need help in finding the date of the 1st day for a specified Week. Lets suppose if I specify the week of the year as 22, I should get the date as 5-28-2007 which is Monday. Is there any function or can I get a script which gives the above requirement? Thanks & Regards, navjak Link to comment https://forums.phpfreaks.com/topic/52614-solved-need-help-in-finding-the-date/ Share on other sites More sharing options...
lake Posted May 23, 2007 Share Posted May 23, 2007 try this ===================================== //function: function getFirstDayInWeek($year,$weekAtYear) { $firstDayInWeek = ""; for($i = 1 ; $i <= 12 ; $i++) { for($j = 1 ; $j <= 31 ; $j++) { if(date("W",strtotime("$year-$i-$j")) == $weekAtYear) { $firstDayInWeek = "$i-$j-$year"; break 2; } } } return $firstDayInWeek; }] //use: $date = getFirstDayInWeek('2007','22'); echo 'the results is: '.$date; Link to comment https://forums.phpfreaks.com/topic/52614-solved-need-help-in-finding-the-date/#findComment-259637 Share on other sites More sharing options...
navjak Posted May 23, 2007 Author Share Posted May 23, 2007 Great Man!! I didnt think this simple logic. It skipped my mind. Thanks for the help!! --navjak Link to comment https://forums.phpfreaks.com/topic/52614-solved-need-help-in-finding-the-date/#findComment-259716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.