[thelist] First Monday bug...

Tris beertastic at gmail.com
Wed Apr 4 06:25:24 CDT 2007


i'm trying to create a drop down tht contains the first Monday of each
week, including the current week.
>From the function, I need to out put 2 bits of data:
1. the date in a happy DB compliant manner (YYYY-MM-DD)
2. the date in a user Friendly way (2nd April etc)

Can a function even output 2 bits of data?

Anyone more clever than me, care to run the code below, and tell me
what I'm doing wrong?

Hmmm

===============

function showMondays($noWeeksBack = 10) {
	$oneDay = 86400;
	$WeekDayNumber = date('w');
	
	for ($i = -1; $i <= $noWeeksBack; $i++) {
		$prevWeeks = $i * 7;
		$prevWeeks = $prevWeeks + 6;
		$showWeekStart[] = date("jS M Y",time() - ($WeekDayNumber +
$prevWeeks) * $oneDay);
		$showFullDate[] = date("Y-m-d",time() - ($WeekDayNumber +
$prevWeeks) * $oneDay);
	}
	
	return $showWeekStart;
	return $showFullDate;
}

	$getMondays = showMondays(4);
	
	foreach ($getMondays as $value) {
		$i++;
		$showDates .= "<option value=\"" . $value["showFullDate"] . "\">" .
$value["showFullDate"] . "</option>\n";
	}

===================

-- 
When a person can no longer laugh at himself, it is time for others to
laugh at him.
Thomas Szasz



More information about the thelist mailing list