php - Getting a decimal qty from subtracting two times -


how subtract 2 time variables each other answer decimal number? time variables this: 07:32:00

i looking this:

$total = $start_time - $end_time echo "$time hours"; 

output this:

5.3 hours

you cant subtract on strings. variable "07:32:00" string.

you have convert time unix timestamp php function strtotime.

and aslo have subtract largest time.

here solution:

echo (strtotime("15:00:00") - strtotime("11:30:00"))/(60*60); 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -