thanks. i find the ansewer...
using this function.
-
function dateDiff($time1, $time2, $precision = 6) {
-
-
if (!is_int($time1)) {
-
$time1 = strtotime($time1);
-
}
-
if (!is_int($time2)) {
-
$time2 = strtotime($time2);
-
}
-
-
-
if ($time1 > $time2) {
-
$ttime = $time1;
-
$time1 = $time2;
-
$time2 = $ttime;
-
}
-
-
-
$intervals = array('year','month','day','hour','minute','second');
-
$diffs = array();
-
-
-
foreach ($intervals as $interval) {
-
-
$diffs[$interval] = 0;
-
-
$ttime = strtotime("+1 " . $interval, $time1);
-
-
while ($time2 >= $ttime) {
-
$time1 = $ttime;
-
$diffs[$interval]++;
-
-
$ttime = strtotime("+1 " . $interval, $time1);
-
}
-
}
-
-
$count = 0;
-
$times = array();
-
-
foreach ($diffs as $interval => $value) {
-
-
if ($count >= $precision) {
-
break;
-
}
-
-
if ($value > 0) {
-
-
if ($value != 1) {
-
$interval .= "s";
-
}
-
-
$times[] = $value . " " . $interval;
-
$count++;
-
}
-
}
-
-
-
return implode(", ", $times);
-
}
-
-
$break= dateDiff("$breakin", "$breakout") . "\n";
-
now i want to add the times intervals...
they user take several breaks in single day. i want to add all the break duration. so i can get the total break time for the user in the whole day...
how to do it?
users first break time duration 30 mins.
second break duration 25 mins
third break duration 20 mins
i am getting like this...
now i want to add 3 break duartions. so the users total break time is 1 hour and 15 mins...
how to do it?