selectedKey) { $this->selectedKey = null; return; } $this->selectedKey = $key; } public function server() { if (!$this->task) { return null; } if ($this->task->application) { return $this->task->application->server; } elseif ($this->task->service) { return $this->task->service->server; } return null; } public function getServerTimezone() { $server = $this->server(); if (!$server) { return 'UTC'; } $serverTimezone = $server->settings->server_timezone; return $serverTimezone; } public function formatDateInServerTimezone($date) { $serverTimezone = $this->getServerTimezone(); $dateObj = new \DateTime($date); try { $dateObj->setTimezone(new \DateTimeZone($serverTimezone)); } catch (\Exception $e) { $dateObj->setTimezone(new \DateTimeZone('UTC')); } return $dateObj->format('Y-m-d H:i:s T'); } }