{"id":1104979,"date":"2016-04-20T11:01:42","date_gmt":"2016-04-20T18:01:42","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/"},"modified":"2016-05-06T09:35:05","modified_gmt":"2016-05-06T16:35:05","slug":"timezone-failing-to-get-abbreviation-for-offset","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/","title":{"rendered":"Timezone failing to get abbreviation for offset"},"content":{"rendered":"<p>I found that all events were displaying the UTC offset rather than the timezone abbreviation.  I&#8217;m not sure if this is specific to us, or if it is common.  After a bit of research, I found that there is a more reliable method to finding the abbreviation than simply passing it to the DateTimeZone class.<\/p>\n<p>These are the changes made to more reliably get the abbreviation:<\/p>\n<p>In Timezones.php, change the abbr function:<\/p>\n<pre><code>\npublic static function abbr( $date, $timezone_string ) {\n        try {\n            if (strpos($timezone_string, &#039;UTC&#039;) === 0) {\n                $offset = substr($timezone_string, 3);\n                \/\/ Calculate seconds from offset\n                list($hours, $minutes) = explode(&#039;:&#039;, $offset);\n                $seconds = $hours * 60 * 60 + $minutes * 60;\n                \/\/ Get timezone name from seconds\n                $tz = timezone_name_from_abbr(&#039;&#039;, $seconds, 1);\n                \/\/ Workaround for bug #44780\n                if ($tz === false) $tz = timezone_name_from_abbr(&#039;&#039;, $seconds, 0);\n\n                $tz_date = date_create($date, new DateTimeZone($tz));\n                $formatted = $tz_date-&gt;format(&#039;T&#039;);\n                return $formatted;\n            }\n\n            $tz_date = date_create($date, new DateTimeZone($timezone_string));\n            $formatted = $tz_date-&gt;format(&#039;T&#039;);\n            return $formatted;\n        } catch (Exception $e) {\n            return &#039;&#039;;\n        }\n\t}\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-1104979","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Timezone failing to get abbreviation for offset -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Timezone failing to get abbreviation for offset -\" \/>\n<meta property=\"og:description\" content=\"I found that all events were displaying the UTC offset rather than the timezone abbreviation. I&#8217;m not sure if this is specific to us, or if it is common. After a bit of research, I found that there is a more reliable method to finding the abbreviation than simply passing it to the DateTimeZone class. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-05-06T16:35:05+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/\",\"name\":\"Timezone failing to get abbreviation for offset -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-04-20T18:01:42+00:00\",\"dateModified\":\"2016-05-06T16:35:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Timezone failing to get abbreviation for offset\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Timezone failing to get abbreviation for offset -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/","og_locale":"en_US","og_type":"article","og_title":"Timezone failing to get abbreviation for offset -","og_description":"I found that all events were displaying the UTC offset rather than the timezone abbreviation. I&#8217;m not sure if this is specific to us, or if it is common. After a bit of research, I found that there is a more reliable method to finding the abbreviation than simply passing it to the DateTimeZone class. [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/","article_modified_time":"2016-05-06T16:35:05+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/","name":"Timezone failing to get abbreviation for offset -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-04-20T18:01:42+00:00","dateModified":"2016-05-06T16:35:05+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/timezone-failing-to-get-abbreviation-for-offset\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Timezone failing to get abbreviation for offset"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1104979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1104979\/revisions"}],"predecessor-version":[{"id":1105494,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1104979\/revisions\/1105494"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1104979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}