a2pl



calculate periode of order on traffic [PHP]

this case must be found when calculating the total price to be paid. where = total number of days (the period of contract ad) * the frequency * price. I finally after a google search on the knuckle with a recurrence period of manual (err TT).
hiks.. I was wrong

I finally found the function to calculate the number of days from the period. [I forgot the site address. but I still quote the name of its author]. so if there is a function of the period. the name of its author do not forget to put on the top of function.

btw, I had chaged a sign the date separator of that function.

here’s the code :

//Fungsi : ambil Tanggal antara startDate dan endDate
// Author : mybenchmarkid at yahoo dot com [keluaran berbentuk array]

function DatesBetween($start_Date, $end_Date){
// get the number of days between the two given dates.
$days = (strtotime($endDate) – strtotime($startDate)) / 86400 + 1;
$startMonth = date(“m”, strtotime($startDate));
$startDay = date(“d”, strtotime($startDate));
$startYear = date(“Y”, strtotime($startDate));
$dates; //the array of dates to be passed back

for($i=0; $i<$days; $i++){
$pDates = explode(“/”, date(“n/j/Y”, mktime(0, 0, 0, $startMonth , ($startDay+$i), $startYear)));
$dates[$i] = $pDates[2].”/”.$pDates[0].”/”.$pDates[1];
}
return $dates;
}

here’s the code :

for example:

period of order on traffic are:

startdate : 2007-01-01

enddate : 2007-02-01

use print_r(DatesBetween (“2007-01-01“, “2007-02-01“));