suma237 Posted August 20, 2007 Share Posted August 20, 2007 The format of the time is (10:42:00 +00:25:15) Thanks Quote 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 Quote 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. Quote 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 Quote 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'); ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.