Re: Week calculating
| From: | Tom Rogers | Date: | Tue, 13 Jan 2004 13:33:30 +0000 |
| Subject: | Re: Week calculating | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174437@lists.php.net to get a copy of this message | ||
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