<?php

// date calculation function
// adds or subtracts a date based upon the input.
// $this_date is a string format of a valid date ie.. "2006/08/11"
// $num_days is the number of days that you would like to add (positive number) or subtract (negative number)

function fnc_date_calc($this_date,$num_days){
    
    $my_time = strtotime ($this_date); //converts date string to UNIX timestamp
    $timestamp = $my_time + ($num_days * 86400); //calculates # of days passed ($num_days) * # seconds in a day (86400)
    $return_date = date("Y/m/d",$timestamp);  //puts the UNIX timestamp back into string format
    
    return $return_date;//exit function and return string
}//end of function

$date_to_test = "2006/08/11";
$days_to_add = 1;

$future_date = fnc_date_calc($date_to_test,$days_to_add);

echo "Test Date is:   ".$date_to_test;
echo "<br>";
echo "Future date is: ".$future_date;
?> 
