In this example we will show you how you can add a week to an existing date object.
In this example we will show you how you can add a week to an existing date object.
The PHP Date add 1 week example code. In the the following example code we will show you how to add one week to any date object in the PHP program.
<?php
//Example to add 1 week to a date object
$currentDate = date("Y-m-d");// current date
//Display the current date
echo "Current Date: ".$currentDate."<br>";
//Add one year to current date
$dateOneWeekAdded = strtotime(date("Y-m-d", strtotime($currentDate)) . " +1 year");
echo "Date After adding one week: ".date('l dS \o\f F Y', $dateOneWeekAdded)."<br>";
?>
The above code example will add one week to $currentDateobject.
The output of the program:
Current Date: 2009-08-30
Date After adding one week: Monday 30th of August 2010