help calc plugin diff data

buc

New Member
Hi, I want a little help with the plugin calc.I have to find the difference between two dates but excluding the working days and holidays, "Saturday and Sunday" and their annual festivals including the Passover.For the normal difference between two dates I used the following formula formulaEg:$ From = strtotime ('{richiesta___dal}');$ To = strtotime ('{richiesta___al}');$ Diff = ($ al $ from) / 86400;return $ diff;and it works pretty well, but how can I calculate what I need?
I already have a function in php I calculate what I need but do not know how to apply it to the plugin calc.
Would you be so genitli to help me please.Thank you very much.
Eg php function:<? Phpgiornilavorativi function ($ StartDate, EndDate $){// Calculation of Easter Day until the last year validfor ($ i = 2015; $ i <= 2037; $ i ++) {$ Easter = date ("Y-m-d", easter_date ($ i));$ Array_pasqua [] = $ Passover;}
// Calculate the respective Pasquetteforeach ($ array_pasqua as $ easter) {list ($ year, $ month, $ day) = explode ("-", $ Easter);$ Pasquetta = mktime (0,0,0, dates ($ month), dates ($ day) + 1, dates ($ year));$ Array_pasquetta [] = $ Easter Monday;}
// These days are always holidays apart from the year$ GiorniFestivi =array ("01-01""04-06""01-06","04-25""05-01""06-02""08-15""10-04""11-01""12-08""12-25","12-26",);
$ Working = 0;
for ($ i = strtotime ($ StartDate); $ i <= strtotime ($ EndDate); $ i = strtotime ("+ 1 day", $ i)){$ Giorno_data = date ("w", $ s); // Check on the day: from 0 (Sun) to 6 (Sat)$ Mese_giorno = date ('m-d', $ i); // Comparison with gg always Holidays
// Finally I verify that the day is not a Saturday, Sunday or public holiday festive variable (Easter Monday);if ($ giorno_data! = 0 && $ giorno_data! = 6 &&! in_array ($ mese_giorno, $ giorniFestivi) &&! in_array ($ i, $ array_pasquetta)){$ Working ++;}
}
return $ working;}
giornilavorativi echo ("02/28/2015", "02/03/2015");?>
 
This code is unreadable, please use appropriate formatting.
Don't use php tags <?
See WIKI for calc element and php code examples.
 
Sorry I hope you now understand better
Hi, I want a little help with the plugin calc.I have to find the difference between two dates but excluding the working days and holidays, "Saturday and Sunday" and their annual festivals including the Passover.​
For the normal difference between two datesI used the following formula.​
Eg:​
$ From = strtotime ('{richiesta___dal}');​
$To = strtotime ('{richiesta___al}');​
$ Diff = ($ al $ from) / 86400;​
return $ diff;​
and it works pretty well, but how can I calculate what I need?​
I already have a function in php I calculate what I need but do not know how to apply it to the plugin calc.​
Would you be so genitli to help me please.​
Thank you very much.​
Eg: php function:​
<?php
function giornilavorativi($dataInizio,$dataFine)
{

for ($i=2015; $i<=2037; $i++) {
$pasqua = date("Y-m-d", easter_date($i));
$array_pasqua[] = $pasqua;
}


foreach($array_pasqua as $pasqua){
list ($anno,$mese,$giorno) = explode("-",$pasqua);
$pasquetta = mktime (0,0,0,date($mese),date($giorno)+1,date($anno));
$array_pasquetta[] = $pasquetta;
}

$giorniFestivi =
array(
"01-01",
"04-06",
"01-06",
"04-25",
"05-01",
"06-02",
"08-15",
"10-04",
"11-01",
"12-08",
"12-25",
"12-26",
);

$lavorativi = 0;

for($i = strtotime($dataInizio); $i<=strtotime($dataFine); $i = strtotime("+1 day",$i))
{
$giorno_data = date("w",$i);
$mese_giorno = date('m-d',$i);


if ($giorno_data !=0 && $giorno_data != 6 && !in_array($mese_giorno,$giorniFestivi) && !in_array($i,$array_pasquetta) )
{
$lavorativi++;
}

}

return $lavorativi;
}

echo giornilavorativi("2015-02-28","2015-03-02");
?>
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top