I have to wait 1/2 hour for some stuff to download so i whipped this together, I think it works
<?
error_reporting (E_ERROR | E_WARNING | E_PARSE);
//The syntax is DateAdd(interval,number,date)
//The interval is a string expression that defines the interval you want to add.
// For example minutes or days, the number is the number of that interval
//that you wish to add, and the date is the date.
//Interval can be one of:
/*
yyyy year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
n Minute
s Second
As far as I can tell, w,y and d do the same thing, that is add
1 day to the current date, q adds 3 months and ww adds 7 days.
If I've missed some subtlety of VBScript, someone please let me know :)
*/
function DateAdd ($interval, $number, $date)
{
$date_elements = split("-" ,$date);
$date= mktime (0, 0,0 ,$date_elements [1], $date_elements[ 2],$date_elements [0]);
$date_time_array = getdate($date);
$hours = $date_time_array["hours"];
$minutes = $date_time_array["minutes"];
$seconds = $date_time_array["seconds"];
$month = $date_time_array["mon"];
$day = $date_time_array["mday"];
$year = $date_time_array["year"];
switch ($interval) {
case "yyyy":
$year +=$number;
break;
case "q":
$year +=($number*3);
break;
case "m":
$month +=$number;
break;
case "y":
case "d":
case "w":
$day+=$number;
break;
case "ww":
$day+=($number*7);
break;
case "h":
$hours+=$number;
break;
case "n":
$minutes+=$number;
break;
case "s":
$seconds+=$number;
break;
}
$timestamp = mktime($hours ,$minutes, $seconds,$month ,$day, $year);
//$timestamp;
return strftime( "%Y-%m-%d",$timestamp);
}
function getmonday($date)
{
$date_elements = split("-" ,$date);
$date2= mktime (0, 0,0 ,$date_elements [1], $date_elements[ 2],$date_elements [0]);
$week=array("sunday"=>0,"monday"=>1,"tuesday"=>2,"wednesday"=>3,"thursday"=>4,"friday"=>5,"saturday"=>6);
$pos=$week[strtolower(date("l",$date2))];
$pos-=1;
return DateAdd("d", ($pos*-1), $date);
}
function weekadd($num_of_weeks)
{
return DateAdd("ww", $num_of_weeks, date("Y")."-01-01");
}
echo "Add three weeks to january first: ".weekadd(3);
echo "<BR>";
echo "The date for monday of that given week is: ".getmonday(weekadd(3));
echo "<BR><h3>BOOO YAAAaA!!!</h3>";
?>