Home Tutorial Php Phpdate PHP Date add 1 week

 
 

Share on Google+Share on Google+
PHP Date add 1 week
Posted on: August 30, 2009 at 12:00 AM
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


 

Advertisement

Related Tags for PHP Date add 1 week:


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.

Posted on: August 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com