Log in
updated 11:29 AM UTC, May 4, 2016

How to increment and decrement days in PHP

Its very easy to increment and decrement days in PHP.

Here is an example which provides ways to increment days/months/years in PHP

$date = date("Y-m-d");

//increment 2 days
$mod_date = strtotime($date."+ 2 days");
echo date("Y-m-d",$mod_date) . "\n";

//decrement 2 days
$mod_date = strtotime($date."- 2 days");
echo date("Y-m-d",$mod_date) . "\n";

//increment 1 month
$mod_date = strtotime($date."+ 1 months");
echo date("Y-m-d",$mod_date) . "\n";

//increment 1 year
$mod_date = strtotime($date."+ 1 years");
echo date("Y-m-d",$mod_date) . "\n";


Run yourself to check the results
Sample test Run (Current date = 2013-02-24):


2013-02-26   // increment 2 days
2013-02-22  //decrement 2 days
2013-03-24  // increment 1 month
2014-02-24  //increment 1 year

Add a comment (0)

  • Written by Madhu V Rao
  • Category: PHP
  • Hits: 11894

Why PHP and MySQL is a popular combination for building websites

Latest statistics show that PHP is widely used and used by ~78% of all the websites. PHP also provides built in functions for communicating with MySQL database , which is a easy to use RDBMS.

Apart from making webdesign and programming easier , These are some of the reasons why PHP & MySQL has advantage over other languages:

  • Both are open source and free.
  • Better Performance :They are designed with Speed as a main goal.
  • PHP and MySQl has wide support from Developer community , so incase there are issues , It can be solved easily.
  • Customizable: Since Both are open source, one can modify to fit their own requirement.
  • Many free frameworks(CMS - Content Management Systems) are available: Joomla, Wordpress, Drupal , etc are some of the top frameworks which uses the PHP and MySQL to provide users tools to develop website easilty.


Add a comment (0)

  • Written by Madhu V Rao
  • Category: PHP
  • Hits: 3986
Follow Us on Twitter
Find Us on Facebook
Follow Us on Google
Follow Us on Pinterest