If you have a Google Places place_id and API key, the following URL will return the hours as a JSON object.
Just be sure to replace "YOUR_PLACE_ID" with your actual Google Places place_id and "YOUR_API_KEY" with your Google Places API key.
https://maps.googleapis.com/maps/api/place/details/json?placeid=YOUR_PLACE_ID&fields=opening_hours&key=YOUR_API_KEY
You will get hours for each day as both day-of-week-number, from 0 to 6, where Sunday = 0, as well as a standard language array. The numbered days are found in result.opening_hours.periods
and the standard language array is result.opening_hours.weekday_text
weekday_text
is simpler to use while periods
will enable you to do things like display the results in different languages.
You can use any server side language you want to parse the response. If you wanted to use an AJAX requestHere is how it might look something like thisin PHP:
var url$url = 'https://maps.googleapis.com/maps/api/place/details/json?placeid=YOUR_PLACE_ID&fields=opening_hours&key=YOUR_API_KEY';
var xhr
$hours_raw = new XMLHttpRequest@file_get_contents($url);
xhr.onload =if function(!empty($hours_raw)
) {
if$hours_json (xhr.status= ==json_decode($hours_raw, 200true) {;
var response =if JSON.parse(xhr.responseText!empty($hours_json['result']['opening_hours']);
) {
var businessHoursArray$business_hours = response.result.opening_hours.weekday_text;$hours_json['result']['opening_hours']['weekday_text'];
}
}
// Use$business_hours theis an array you can use however you like
}e.g.
}echo '<ul>';
xhr.openforeach ('GET',$business_hours url,as true$weekday); {
xhr echo '<li>' .send(); $weekday . '</li>';
}
echo '</ul>';