I am using the google direction API for estimated duration calculation between two places including traffic. I am using the departure time : Friday 22-January-2016 time: 12:00 PM(IST). As per the google API if we need the traffic time then we need to include the departure time in UTC and departure time should be either current time or greater. See below link
https://developers.google.com/maps/documentation/directions/intro?hl=en
Now my problem is that my departure time is "Friday 22-January-2016 time: 12:00 PM(IST)" (1453464000) when I am going to convert it into UTC then it will be "Friday 22-January-2016 time: 6:30 AM" (1453444200).
Now when I am passing this time in google direction API call then its showing the error:
[error_message] => departure_time is in the past. Traffic information is only available for future and current times. This is because this time has been passed in IST.
This is because in this situation UTC is smaller than IST. Now how can I manage this?
See my code below
$start = 'Vijay Nagar, Indore, Madhya Pradesh, India';
$finish = 'Regal Cir, New Agarwal Nagar, Indore, Madhya Pradesh, India';
$url = 'https://maps.googleapis.com/maps/api/directions/xml?origin=' .$start . '&destination=' . $finish . '&sensor=false&departure_time=1453533717&mode=driving&traffic_model=pessimistic&key=AIzaSyC7h7m5bRs-BZwk0XTXEQTB74dZujeLzZs';
Please suggest any solution.
Your timestamps are off.
1453464000 == 2016-01-22 12:00:00 UTC == 2016-01-22 17:30:00 India
1453444200 == 2016-01-22 06:30:00 UTC == 2016-01-22 12:00:00 India
For 06:30 India time, that would be:
2016-01-22 06:30:00 India == 2016-01-22 01:00:00 UTC == 1453424400
India is 5 hours and 30 minutes ahead of UTC. Additionally, whenever you are representing a timestamp in numerical form, that is almost always UTC based already.