suma237 Posted August 20, 2007 Share Posted August 20, 2007 The format of the time is (10:42:00 +00:25:15) Thanks Link to comment https://forums.phpfreaks.com/topic/65778-how-to-add-time104200-002515/ Share on other sites More sharing options...
vijayfreaks Posted August 20, 2007 Share Posted August 20, 2007 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 Link to comment https://forums.phpfreaks.com/topic/65778-how-to-add-time104200-002515/#findComment-328649 Share on other sites More sharing options...
suma237 Posted August 20, 2007 Author Share Posted August 20, 2007 no .The output is incorrect. Link to comment https://forums.phpfreaks.com/topic/65778-how-to-add-time104200-002515/#findComment-328655 Share on other sites More sharing options...
vijayfreaks Posted August 20, 2007 Share Posted August 20, 2007 Hi.. yea.. but the way ma going that is correct.. what u say? Regards, Vijay Link to comment https://forums.phpfreaks.com/topic/65778-how-to-add-time104200-002515/#findComment-328664 Share on other sites More sharing options...
sasa Posted August 20, 2007 Share Posted August 20, 2007 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'); ?> Link to comment https://forums.phpfreaks.com/topic/65778-how-to-add-time104200-002515/#findComment-328923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.