HI EVERYONE,

I have one problem, as i calculate two time like today i have worked 9.43 hours and 2nd day i worked 8.20 hours when i calculate total time of these two day then it shows 17.63 hours but i want to show this with the help of php , this should come as like 18.03 hours.

How i can do this , please help me.

regards,
Gagan

Just use the following code. Simple and easy to use.

//set the values
$value_a=9.43;
$value_b=8.20;

//now to calculate
$value=$value_a+$value_b;
$valuesplit=explode('.',$value);
if(!isset($valuesplit[1]))
    {
    $endvalue=$valuesplit[0];
    } else {
    if ($valuesplit[1]>=60)
        {
        $valuesplit[1]='0.'.$valuesplit[1];
        $valuesplit[1]=$valuesplit[1]-0.60;
        $valuesplit[0]+=1;
        $valuesplit[1]=preg_replace('/[^.]+[.](.*)/','$1',$valuesplit[1]);
        }
    $endvalue=$valuesplit[0].'.'.$valuesplit[1];
    }

//now to echo the value
echo $endvalue;

change the separator to :
strtotime functions think that x.y is a fraction x:y is a time
$a = 9.43 = 9:25
$b = 8.20 = 8:12
= 17.63 = 17:37

You want
$a = 9:43
$b = 8:20
= 18:03
then you can just add the hours with mktime(strtotime($a + $b))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.