Home Tutorial Php Phpdate PHP Date add 1 week

 
 

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


 

Related Tags for PHP Date add 1 week:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.