Subtract time from time with php -


hi have database has pages visitor has viewed , time landed on page. trying take time visitor views page time visitor views page b , subtract b how long visitor stayed on page for.

at moment, in example difference 2 seconds result returned zero, because 2 seconds low number result rounded up?

here code.

$a = new datetime('09:14:52'); $b = new datetime('09:14:54'); $interval = $a->diff($b);  echo $interval->format("%h"); 

thanks

<?php $a = strtotime('09:14:52'); $b = strtotime('09:14:54'); $interval = $b-$a;  echo $interval. " seconds"; ?> 

and own code correct too, format label hour not second. try

<?php  $a = new datetime('09:14:52'); $b = new datetime('09:14:54'); $interval = $a->diff($b);  echo $interval->format("%s");  ?> 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -