performance - php - calculating distance divded by time -


how divide decimal time queried database time format.

any idea?

$time = date($entity->gettime()->format('h:i:s')); $speed = $distance/$time 

which wrong , if time 00:40:00, division 0 error.

i unable convert seconds because php takes datetime time format in database.

i propose time in seconds, need convert minutes , hours seconds.

$seconds = date($entity->gettime()->format('s')); $minutes = date($entity->gettime()->format('i')); $hours = date($entity->gettime()->format('h')); $time = $hours * 3600 + $minutes * 60 + $seconds; $speed = $distance/$time; 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -