Get Future Date with PHP

Free Scripts :: PHP :: Date and Time :: Get Future Date with PHP

Author: Salman Javaid

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

Comments

No comments. Be the first one.

Leave a comment

Full Name*
Comments*
Security Code*

Our Partners

Getty Icons  Salman Creations
Free High Quality Images  Learn Free Languages 
Opal Hosting  R-Tech Solutions
  • Submit a Script

    Click here to submit your script.