In reading the documentation https://developers.google.com/maps/documentation/distance-matrix/intro the departure_time
must be set in the future and based on January 1, 1970 UTC 00:00:00
. This tells me that if I run a Distance Matrix API request during my working day in CT time zone I need to calculate the number of seconds from 1/1/1970 00:00:00 UTC
to some future time say 03:00:00
on tomorrow morning for UTC-6
(CT time). Example: today is 5/31/2017
, the number of seconds calculated should be the number of seconds between 1/1/1970 00:00:00
and 1/1/2017 03:00:00
– 6 hours (1496286000 – 360 = 1496285640
) I insert departure_time=1496285640
. Will someone who has successfully used this optional parameter please confirm.
Asked
Active
Viewed 2,004 times
5

alessandrio
- 4,282
- 2
- 29
- 40

CFRBill
- 51
- 4
-
Facing the same dilemma. Seems to be departure time can be in local to compare against 1/1/1970 00:00:00 UTC. Meaning if my time is UTC + 8, and I'm looking for duration at 9 am; I calculate departure as 10/04/2018 09:00:00 - 01/01/1970 00:00:00. Though the result given in this API is not in accordance with the Google Map distance/duration. – Randeep Singh Apr 10 '18 at 05:25
-
You shared an easier way to look at calculating the time and, from what I can tell, it appears to work. Yes the API documentation could be a bit better. Thank you. – CFRBill Apr 11 '18 at 11:54