In this tutorial you will learn how to PHP date increment in a PHP web application.
PHP date increment
In this tutorial you will learn how to PHP date increment in a PHP web application. In this tutorial date increment one day , one month and one year respectively. The code of "php-date-increment.php" given below :
<?php $date="2011-02-28"; echo "Date :: ".$date."<br>"; $date_arr=explode('-',$date); echo "Date increment one day =>"; $date2=Date("Y-m-d",mktime(0,0,0,$date_arr[1],$date_arr[2]+1,$date_arr[0]))."<br>"; echo $date2; echo "Date increment one month =>"; echo Date("Y-m-d",mktime(0,0,0,$date_arr[1]+1,$date_arr[2],$date_arr[0]))."<br>"; echo "Date increment one year =>"; echo Date("Y-m-d",mktime(0,0,0,$date_arr[1],$date_arr[2],$date_arr[0]+1))."<br>"; ?>
Output :
When run "php-date-increment.php" display output as :
[ 0 ] Comments