Hi,
Tuesday, January 13, 2004, 11:07:05 PM, you wrote:
n> Greetings;
n> I need a help here ... I want to make function that return the dates of
n> Tuesdays in a given year
n> Example::
n> Calc_Tuesdays (2004);
n> //and it should return or echo
n> 2004-01-06
n> 2004-01-13
n> 2004-01-20
n> 2004-01-27
n> 2004-02-03
n> .
n> .
n> etc .... ofcourse it should echo 5 Tuesdays in March by example
n> so it should depends on the year not only current day+7
n> any help please !!
n> Nabil
Get the first tuesday, then keep adding 7 days until year end:
$year = 2004;
$start = strtotime($year.'-1-1');
$tuesday = strtotime('1st tuesday', $start);
while($year == 2004){
echo date('d/m/Y',$tuesday).'<br>';
$tuesday += (7*24)*60*60;
$year = intval(date('Y',$tuesday));
}
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php