w3resource
php Programming Exercies

PHP Date Exercises : Increment date by one month

PHP date: Exercise-24 with Solution

Write a PHP script to increment date by one month.

Sample date : 2012-12-21

Sample solition:

PHP Code:

<?php
$dt = strtotime("2012-12-21");
echo date("Y-m-d", strtotime("+1 month", $dt))."\n";
?>

Sample Output:

2013-01-21

Flowchart :

Flowchart: Increment date by one month

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to get the current month and previous three months.
Next: Write a PHP script to get the current date in Italian.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming