From 49e2808b98a1f9e2aeee9c07ec25b4cdecaf6e84 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Thu, 24 Feb 2022 15:58:30 +0100 Subject: [PATCH] Fix timezone issue with add-to-google link of the booking page (#1216) --- application/controllers/Appointments.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index ce91ad8e..0b762020 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -336,10 +336,18 @@ class Appointments extends EA_Controller { $company_name = $this->settings_model->get_setting('company_name'); - $appointment_start_instance = new DateTime($appointment['start_datetime']); + $provider_timezone_instance = new DateTimeZone($provider['timezone']); + + $utc_timezone_instance = new DateTimeZone('UTC'); + + $appointment_start_instance = new DateTime($appointment['start_datetime'], $provider_timezone_instance); + + $appointment_start_instance->setTimezone($utc_timezone_instance); - $appointment_end_instance = new DateTime($appointment['end_datetime']); + $appointment_end_instance = new DateTime($appointment['end_datetime'], $provider_timezone_instance); + $appointment_end_instance->setTimezone($utc_timezone_instance); + $add_to_google_url_params = [ 'action' => 'TEMPLATE', 'text' => $service['name'],