Get Future Date with PHP
Free Scripts :: PHP :: Date and Time :: Get Future Date with PHP
Website: http://www.salman.be
- Get future date with php
- How to get date after number of days with php
Function accepts date, number of days and output date format parameters and returns future date.
Function
function GetFutureDate($strDate,$strFutureDays,$strFormat) {
$strDate=date("Y",strtotime($strDate)).date("m",strtotime($strDate))
.date("d",strtotime($strDate));
if (strlen($strDate) == 8) {
$strStartYear = substr($strDate,0,4);
$strStartMonth = substr($strDate,4,2);
$strStartDay = substr($strDate,-2);
$startDate = mktime (0,0,0,$strStartMonth,$strStartDay,$strStartYear);
$finishDate = $startDate + ($strFutureDays * 24 * 60 * 60);
$finishDate = date("Ymd",$finishDate);
return date($strFormat,strtotime($finishDate));
}
}
Calling The Function
echo GetFutureDate('2010/04/15',55,'d/m/Y');
Output
09/06/2010




