title: php - Get driving distance between two points using Google Maps API and calculate time
body: <p>How to display time example 16:00 any have idea how to make this?</p>
  
  <pre><code>function GetDrivingDistance($lat1, $lat2, $long1, $long2)
          {
              $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&amp;destinations=".$lat2.",".$long2."&amp;mode=driving&amp;language=de";
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, $url);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
              curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
              $response = curl_exec($ch);
              curl_close($ch);
              $response_a = json_decode($response, true);
              $dist = $response_a['rows'][0]['elements'][0]['distance']['text'];
              $time = $response_a['rows'][0]['elements'][0]['duration']['text'];
  
          return array('distance' =&gt; $dist, 'time' =&gt; $time);
      }
      //$pickuplocation = 'Herbststrasse 5';
      //$droplocation = 'Pastorstrasse 5';
      $coordinates1 = get_coordinates('wien', 'Stefan Esders Platz 1', '');
      $coordinates2 = get_coordinates('wien', 'Pastorstrasse 1', '');
      if ( !$coordinates1 || !$coordinates2 )
      {
          echo 'Bad address.';
      }
      else
      {
          $dist = GetDrivingDistance($coordinates1['lat'], $coordinates2['lat'], $coordinates1['long'], $coordinates2['long']);
          echo 'Entfernung: &lt;b&gt;'.$dist['distance'].'&lt;/b&gt;&lt;br&gt;Fahrzeit: &lt;b&gt;'.$dist['time'].'&lt;/b&gt;';
      }
      ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Entfernung: 662 km Fahrzeit: 6 Stunden, 56 Minuten</p>
  </blockquote>
  
  <p>I need to display time example 6:56 any can help?</p>