Share on Google+Share on Google+

PHP Date add 1 week

Advertisement
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


 

Advertisements

Advertisement

Posted on: August 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.