Jump to content

[SOLVED] Need help in finding the Date


navjak

Recommended Posts

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

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.