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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -