
- You are not logged in. | Login
January 16, 2007 10:52 am
- purplebean
- Member


I can't sort date properly. Please help
Hi al,
I'm new to PHP and can't work out how to do this:
I'd like to list the short date of the next 4 'thursdays' in a drop-down menu, e.g.
The date today is 01/02/2007 so ideally the drop down would contain the following options:
01/04/2007
01/11/2007
01/18/2007
01/25/2007
Please help
January 16, 2007 10:54 am
- R@mzess
- Member


Re: I can't sort date properly. Please help
PHP Code:
//get Numeric representation of today's day
$day = date('w');
//Get the day difference
if ($day <= 4) {
$dayDiff = 4 - $day;
} else {
$dayDiff = (6 - $day + 1) + 4 ;
}
for ($i=0;$i<4;$i++) {
$Thursdays[] = date('m-d-Y',mktime(0,0,0,date('m'),date('d') + $dayDiff + (7 * $i),date('Y')));
}
print_r($Thursdays);


