- 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
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

Leave A comment
Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *