3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $Fecha = "2016-01-27 11:50:19"; function CalcularTiempo($Timestamp){ $Segundos = strtotime('now') - strtotime($Timestamp); return intval($Segundos); } function CalcularVelocidad($Distancia, $Tiempo){ $Velocidad = $Distancia / $Tiempo; $Velocidad = $Velocidad * (1/1000) * 3600 / 1; return $Velocidad; } 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 Chlja
Output for 5.6.28, 7.0.20 - 7.2.0
0.17755220132171
Output for 7.0.6
4.3291005529817E-5
Output for 7.0.5
7.446631141869E-5
Output for 7.0.4
0.00011466687909934
Output for 7.0.3
9.6708143265512E-5
Output for 7.0.2
8.9329601464981E-5
Output for 7.0.1
8.7561402931328E-5
Output for 7.0.0
8.3125439711181E-5
Output for 5.6.21
5.17905713427E-5
Output for 5.6.20
6.7448724828775E-5
Output for 5.6.19
0.0001221463741922
Output for 5.6.18
0.00010343923031591
Output for 5.6.17
9.4626509532165E-5
Output for 5.6.16
8.1715295687774E-5
Output for 5.6.15
8.035156702664E-5
Output for 5.6.14
6.3673570425752E-5
Output for 5.6.13
6.2846904299427E-5
Output for 5.6.12
5.9397201123479E-5
Output for 5.6.11
5.6520878250012E-5
Output for 5.6.10
5.5832098909427E-5
Output for 5.6.9
5.4471703001951E-5
Output for 5.6.8
5.3106262737613E-5
Output for 5.5.35
4.2717787483259E-5
Output for 5.5.34
6.6464785302889E-5
Output for 5.5.33
0.00011885660347347
Output for 5.5.32
9.8984807289553E-5
Output for 5.5.31
9.2634296166926E-5
Output for 5.5.30
7.6552098054463E-5
Output for 5.5.29
6.1608354148584E-5
Output for 5.5.28
5.8601301660021E-5
Output for 5.5.27
5.7875260121236E-5
Output for 5.5.26
5.5144426927033E-5
Output for 5.5.25
5.3768811365241E-5
Output for 5.5.24
4.2245282961831E-5
Output for 5.4.44 - 5.4.45
0.17725969357653
Output for 5.4.42 - 5.4.43
0.17718671716913
Output for 5.4.40 - 5.4.41
0.17711380082462
Output for 5.4.38 - 5.4.39
0.17704094446887
Output for 5.4.36 - 5.4.37
0.17696814802789
Output for 5.4.34 - 5.4.35
0.17689541142779
Output for 5.3.29, 5.4.31 - 5.4.32
0.17675011745537
Output for 5.4.29 - 5.4.30
0.17667755993589
Output for 5.4.27 - 5.4.28
0.176605061963
Output for 5.4.25 - 5.4.26
0.17653262346342
Output for 5.4.23 - 5.4.24
0.17646024436401
Output for 5.3.28, 5.4.22
0.17638792459173
Output for 5.4.20 - 5.4.21
0.17631566407367
Output for 5.4.18 - 5.4.19
0.17624346273703
Output for 5.3.27, 5.4.17
0.17617132050914
Output for 5.3.26, 5.4.15 - 5.4.16
0.17609923731744
Output for 5.3.24 - 5.3.25, 5.4.13 - 5.4.14
0.1760272130895
Output for 5.3.22 - 5.3.23, 5.4.12
0.17595524775299