//
function date_return($days,$start_date=NULL)
{
if ($start_date!="")
{
$start_datex = explode("-",$start_date);
$day=$start_datex[0];
$month=$start_datex[1];
$year=$start_datex[2];
}
else
{
$day=date(d);
$month=date(m);
$year=date(y);
}
$default_month=$month;
while($days>0)
{
$x = cal_days_in_month(CAL_GREGORIAN,$month,$year);
if($default_month==$month)
{
if($day+$days > $x)
{
$days=$days-($x-$day);
$day=0;
if ($month==12)
{
$year++;
$month=01;
}
else
{
$month++;
}
}
else
{
$day=$day+$days;
$days=0;
}
if ($day<10 style="color: rgb(51, 51, 255);">strlen($day)<2){$day="0".$day;} style="color: rgb(51, 51, 255);">strlen($month)<2){$month="0".$month;} style="color: rgb(51, 51, 255);">strlen($year)<2){$year="0".$year;}> $x)
{
$days=$days-($x-$day);
$day=0;
if ($month==12)
{
$year++;
$month=01;
}
else
{
$month++;
}
}
else
{
$day=$days;
$days=0;
}
if ($day<10 style="color: rgb(51, 51, 255);">strlen($day)<2){$day="0".$day;} style="color: rgb(51, 51, 255);">strlen($month)<2){$month="0".$month;} style="color: rgb(51, 51, 255);">strlen($year)<2){$year="0".$year;} date="$day." style="color: rgb(0, 153, 0);">return $date;
}
//
Returns a date after you give it a number of days and a starting date. You can leave the start date blank , and it will give the current date as a start date :).
For example, you can calculate when does a customer have to pay you if he applied for a number of days for your product or service. the function will give you the exact date.
A lot of strings are cut and calculated in order to show a good date, with a 0 in front of a number if the number is smalled than 10.
To call the function you can type:
< ?php $date=date_return("30"); //will show a date 30 days from now
$date=date_return("30","12-03-2001"); //will show a date 30 days from 12-03-2001
? >
If you wish to sate a starting date, you need to make it exactly like this:
day-month-year, separated by a "-".
That's all!