Heres a short function to calc the difference between 2 dates in d/m/y format.
function daycount($d1,$d2) {
// strtotime doesn't like d/m/y format, so change sequence to m/d/y'
$a1 = explode ('/', $d1);
$a2 = explode ('/', $d2);
$t1 = strtotime("$a1[1]/$a1[0]/$a1[2]"); // convert to time in seconds
$t2 = strtotime("$a2[1]/$a2[0]/$a2[2]");
$days = 1 + ($t2 - $t1) / (3600 * 24);
return $days;
}
$date_from = '3/6/03';
$date_to = '6/6/03';
$entitlement = 18; // you probably get this from your database
$leave_to_date = 0; // you probably get this from your database too
$duration = daycount($date_from, $date_to);
$balance = $entitlement - $leave_to_date - $duration;
echo "Duration : $duration ";
echo "<br><br>";
echo "Balance : $balance";
hth