Saturday, September 12, 2015

PHP get next date of the current date

The following function gives the next date of the date entered.

For date format: 2014-02-15

function nextDate($date)
  {
 $dateArray=explode('-',$date);
 $tomorrow = mktime(0,0,0,$dateArray[1],$dateArray[2]+1,$dateArray[0]);
 return date("Y-m-d", $tomorrow);
  }
 
  Usage of the function is as follows:
 
  $date = "2014-06-01";
 
  echo nextDate($date);
 
  Ouput is: 2014-06-02
 
For date format: 2014/02/15

function nextDate($date)
  {
 $dateArray=explode('/',$date);
 $tomorrow = mktime(0,0,0,$dateArray[1],$dateArray[2]+1,$dateArray[0]);
 return date("Y-m-d", $tomorrow);
  }
 
  Usage of the function is as follows:
 
  $date = "2014/06/01";
 
  echo nextDate($date);
 
  Ouput is: 2014/06/02

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...