leena,
use the date's timestamp to perform a subtraction.
try this:
<?php
get the current unix timestamp
$ts = time();
figure out what 7 days is in seconds
$one_week = 7 24 60 * 60;
make today's date based on current timestamp
$today = date( "Y-m-d", $ts );
make last week's date based on a past timestamp
$one_week_ago = date( "Y-m-d", ( $ts - $one_week ) );
?>
<p><b>Today:</b> <?php echo $today; ?></p>
<p><b>One week ago:</b> <?php echo $one_week_ago; ?></p>
output:
Today: 2001-08-27
One week ago: 2001-08-20
hope this helps. 🙂
-nick (http://www.nickbouton.com/)