In PHP, how to subtract $Longitude_1 = 72.8790721063599
from $Longitude_2 = 82.22
?
These are decimal degree values from Google geocoding
.
I need to find the difference and convert it into time.
The time value comes close to 40 minutes as I know in this case.
Also, 1 Degree = 4 mins and not 60 mins when it comes to time differences from longitudinal positions. So if I have the coordinate difference in degrees, I can convert the same to time units. It is to get to the Local Mean Time at the concerned longitude!
Addressing what I see to be your core questions here:
Well, how do you get the difference of values which are in DD format?
$Longitude_2 = 82.22;
$Longitude_1 = 72.8790721063599;
//get the difference
$diff = $Longitude_2 - $Longitude_1; //9.3409278936401
and then convert the values to Degrees so that time can be obtained in the end.
Your answer, stored in $diff
, is already in decimal degrees, so there's nothing to convert. Per your source, 1 degree = 4 minutes time, so simply multiply:
//get the time value
$diff_time = $diff * 4; //37.3637115745604
So, the actual time value is close to 37 minutes for your particular case.