Actually, there's an easier way:
[man]strtotime[/man]("TIME SPAN");
So...
1 Week ago: $date = [man]strtotime[/man]("-1 week");
2 Weeks ago: $date = [man]strtotime[/man]("-2 weeks");
1 Week ahead: $date = [man]strtotime[/man]("+1 week");
The [man]strtotime/man function can take any "English" date and returns a unix timestamp. From that timestamp, you just send it as the second parameter of the [man]date/man function:
$date = [man]date[/man]('Y-m-d', $date);
Easy as pie... 2 lines (or 3 or 4) and no messy "calculations"....
This is not to say that the above post is wrong, but this can be a better/cleaner way to do what you want.
Now, if you want to compare the dates, keep them in the unix timestamp format. So you'd have:
$date = 'some date';
$odate = strtotime($date);
$today = time(); // Returns current unix timestamp
$week = strtotime("+1 week");
$tweek = strtotime("+2 weeks");
if($odate < $week)
{
// Less than 1 week
}
elseif($odate >= $week && $odate < $tweek)
{
// 1 week, to up to 2 weeks
}
else
{
// Over 2 weeks
}