Date Manipulation

Hi,

I am trying to manipulate dates using PHP, specifically weeks. I’m in a situation where I want to add two weeks to the current week number, but obviously I can’t just add two if the week number is 51 (in some casses) or 52 or 53 in all cases. It would also need to then add another 1 to the year etc. Is there any in built function(s) that would allow PHP to be able to do this. If it helps I also have the MySQL format style date for Monday - Friday, so could convert to a timestamp and back, although would like to do this as simply as possible with no overhead.

To add two weeks (1,209,600 seconds) to the current week number:

echo date("W", time()+1209600);

If it was the 52nd week and you added two weeks like above the year would be automatically adjusted to the next one.

Try this out to see it in action:

$start = strtotime('December 30 2010');
echo date('M-d-Y', $start) . "<br />";
echo date("W", $start) . "<br />";

$start = $start + 1209600;
echo date('M-d-Y', $start) . "<br />";
echo date("W", $start) . "<br />";