3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $Fecha = "2016-01-27 11:00:19"; function CalcularTiempo($Timestamp){ $Segundos = strtotime('now') - strtotime($Timestamp); return intval($Segundos); } function CalcularVelocidad($Distancia, $Tiempo){ return ($Distancia / $Tiempo) / 1000; } function CalcularDistancia($OrigenLat, $OrigenLon, $DestinoLat, $DestinoLon){ $R = 6371; $dLat = ($DestinoLat - $OrigenLat) * (pi() / 180); $dLon = ($DestinoLon - $OrigenLon) * (pi() / 180); $a = sin($dLat / 2) * sin($dLat / 2) + cos($OrigenLat * (pi() / 180)) * cos($DestinoLat * (pi() / 180)) * sin($dLon / 2) * sin($dLon / 2); $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); return ($R * $c) * 1000; } $Tiempo = CalcularTiempo($Fecha); $Distancia = CalcularDistancia(38.278096798610605,-0.6911851008339024,38.2788421664234,-0.6901980479164007); $Velocidad = CalcularVelocidad($Distancia, $Tiempo); echo $Velocidad; ?>
based on XrSh7
Output for 5.6.28, 7.0.20 - 7.2.0
2.7226557858487E-5
Output for 7.0.6
1.2021658925186E-8
Output for 7.0.5
2.0674376605957E-8
Output for 7.0.4
3.1826540284419E-8
Output for 7.0.3
2.6845336955311E-8
Output for 7.0.2
2.4798383297867E-8
Output for 7.0.1
2.4307815338358E-8
Output for 7.0.0
2.3077077534062E-8
Output for 5.6.21
1.4381088555079E-8
Output for 5.6.20
1.8726967089851E-8
Output for 5.6.19
3.3900771229165E-8
Output for 5.6.18
2.8712479341167E-8
Output for 5.6.17
2.626787321052E-8
Output for 5.6.16
2.2685823208984E-8
Output for 5.6.15
2.2307435560221E-8
Output for 5.6.14
1.7679269291127E-8
Output for 5.6.13
1.744984439976E-8
Output for 5.6.12
1.6492407890386E-8
Output for 5.6.11
1.5694071151758E-8
Output for 5.6.10
1.5502895069054E-8
Output for 5.6.9
1.5125297115738E-8
Output for 5.6.8
1.4746290023804E-8
Output for 5.5.35
1.1862542218461E-8
Output for 5.5.34
1.8453907925214E-8
Output for 5.5.33
3.2988474643994E-8
Output for 5.5.32
2.7476878415825E-8
Output for 5.5.31
2.5715199841305E-8
Output for 5.5.30
2.1253149801697E-8
Output for 5.5.29
1.7106095466248E-8
Output for 5.5.28
1.6271506072986E-8
Output for 5.5.27
1.6069989022921E-8
Output for 5.5.26
1.5312022458396E-8
Output for 5.5.25
1.4930196373325E-8
Output for 5.5.24
1.1731352051068E-8
Output for 5.4.45
2.7183223182496E-5
Output for 5.4.44
2.7170867171958E-5
Output for 5.4.42 - 5.4.43
2.7158522389054E-5
Output for 5.4.41
2.7152354203184E-5
Output for 5.4.40
2.7140026233057E-5
Output for 5.4.38 - 5.4.39
2.7133866444988E-5
Output for 5.4.36 - 5.4.37
2.7127709452375E-5
Output for 5.4.34 - 5.4.35
2.7121555253316E-5
Output for 5.3.29, 5.4.32
2.711540384591E-5
Output for 5.4.28 - 5.4.31
2.7109255228258E-5
Output for 5.4.23 - 5.4.27
2.7103109398462E-5
Output for 5.3.28, 5.4.18 - 5.4.22
2.7096966354628E-5
Output for 5.3.23 - 5.3.27, 5.4.13 - 5.4.17
2.709082609486E-5
Output for 5.3.22, 5.4.12
2.7084688617267E-5