Jump to content

how to add time(10:42:00 +00:25:15)


suma237

Recommended Posts

Hi..

 

    you can do that following ways..

<?php
$time1=mktime(10,42,0);
$time2=mktime(0,25,15);

$diff=$time1-$time2;
if($diff < 0 && $time1 < $time2)
$diff = (-1*$diff);

$newtime=$time1+$diff;	
echo date("H:i:s",$newtime);
?>

 

Regards,

Vijay

try

<?php
function sum_time($a, $b){
$tmp = 0;
$a = explode(':',$a);
$b = explode(':',$b);
$c = array();
for ($i = 2; $i >=0; $i--){
	$tmp += $a[$i] + $b[$i];
	$c[$i] = sprintf('%02u', $tmp % 60);
	$tmp = floor($tmp / 60); 
}
return implode(':', array_reverse($c));
}

echo $result = sum_time('10:42:00','00:25:15');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.