// added style sheet Your Beeronaut Events End Date needs to be the same as or later than the Start Date. Please use 'yyyy-mm-dd' format."; } //This inserts the date variables into the Google API request $response = file_get_contents("https://www.googleapis.com/calendar/v3/calendars/4fnme9rmk20odatisd2jks1pvo%40group.calendar.google.com/events?orderBy=startTime&singleEvents=true&timeMax=" . $EndDate . "T23%3A59%3A00-06%3A00&timeMin=" . $SttDate . "T03%3A00%3A00-06%3A00&fields=items(description%2Cend%2Clocation%2Cstart%2Csummary)&key=AIzaSyBoS0tmxAzRjdXkh_G1u5yu1ONua1MEo7s"); //The section below decodes the json response into an associative array. I have managed to work out how to populate the "array within an array" with entries for DATE format or DATETIME format. */ //this function should return the array within one of the results $decoded_response = json_decode($response, true); for ($i = 0; $i < count($decoded_response["items"]); $i++) { //This handles the two different elements of the 'start' array within the 'items' array where the start and end dates might be stored if (isset($decoded_response['items'][$i]['start']['dateTime'])) { $start_GTime = ($decoded_response['items'][$i]['start']['dateTime']); $Gdate = new DateTime($start_GTime); echo "

" . $Gdate->format('l, F j')."

"; // echo "" . $Gdate->format('g:i a'); $end_GTime = ($decoded_response['items'][$i]['end']['dateTime']); $Gend = new DateTime($end_GTime); echo "" . $Gdate->format('g:i') . " "; $Ampm2 = ($Gend->format('a')); $Ampm1 = ($Gdate->format('a')); if($Ampm1<>$Ampm2){ echo " " . $Ampm1;} if ($Gdate<$Gend){ echo "- " . $Gend->format('g:i a') . " ";} else { echo " " . $Ampm1 . " ";} //Inserts beer mug emoji echo json_decode('"\uD83C\uDF7A"'); } if (isset($decoded_response['items'][$i]['start']['date'])) { $start_day = ($decoded_response['items'][$i]['start']['date']); $Gdate= new DateTime($start_day); // echo "

" . $Gdate->format('l, F j')."

"; } //prints out the rest of the event information echo " " . $decoded_response["items"][$i]["summary"] . "

"; echo "" . $decoded_response["items"][$i]["location"] . " "; // stripcity test $stripcity = urlencode(strip_tags($decoded_response['items'][$i]['location'])); $shortcode=stripos($stripcity,"%26%238209"); $stripcity=substr($stripcity,0,$shortcode-4); $shortcode=strripos($stripcity,"%28"); if ($shortcode > 0) $stripcity=substr($stripcity,0,$shortcode-1); echo (""); echo json_decode('"\uD83C\uDF0E"'); echo ("
"); //end stripcity echo "" . nl2br($decoded_response["items"][$i]["description"]) . "

"; } echo "


"; ?>