{"id":41336,"date":"2016-02-17T19:03:21","date_gmt":"2016-02-17T19:03:21","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=41336"},"modified":"2016-03-17T12:16:50","modified_gmt":"2016-03-17T12:16:50","slug":"how-to-get-present-time-of-any-time-zone-in-opencart","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/","title":{"rendered":"How To Get Present Time Of Any Time Zone In Opencart"},"content":{"rendered":"<p>Normally we can get local date and time by using php date function but today we will learn to get present time of different time zone. Here is the code<\/p>\n<pre class=\"brush:php\">$date = new DateTime('2014-06-1', new DateTimeZone('America\/Mexico_City'));\r\n$zone = $date-&gt;format('P');\r\n$query = \"SELECT CONVERT_TZ(NOW(), @@session.time_zone, '$zone') as time;\";\r\n$data = $this-&gt;db-&gt;query($query)-&gt;row;\r\n$time = date(\"Y-m-d H:i:s\", strtotime($data['time']));   \r\n\r\n<\/pre>\n<pre class=\"brush:php\">If we print the $date then it gives DateTime object\r\n\r\n<\/pre>\n<pre class=\"brush:php\">DateTime Object\r\n(\r\n    [date] =&gt; 2014-06-01 00:00:00.000000\r\n    [timezone_type] =&gt; 3\r\n    [timezone] =&gt; America\/Mexico_City\r\n)\r\n\r\n<\/pre>\n<pre class=\"brush:php\">If we print the $zone then it gives\r\n\r\n<\/pre>\n<pre class=\"brush:php\">-05:00\r\n\r\n\r\nIf we print the $data then it gives<\/pre>\n<pre class=\"brush:php\">Array\r\n(\r\n    [time] =&gt; 2016-02-17 13:44:42\r\n)  \r\n\r\n<\/pre>\n<pre class=\"brush:php\">If we print the $time then it gives\r\n\r\n\r\n<\/pre>\n<pre class=\"brush:php\">2016-02-17 13:52:59<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Normally we can get local date and time by using php date function but today we will learn to get present time of different time zone. Here is the code $date = new DateTime(&#8216;2014-06-1&#8217;, new DateTimeZone(&#8216;America\/Mexico_City&#8217;)); $zone = $date-&gt;format(&#8216;P&#8217;); $query = &#8220;SELECT CONVERT_TZ(NOW(), @@session.time_zone, &#8216;$zone&#8217;) as time;&#8221;; $data = $this-&gt;db-&gt;query($query)-&gt;row; $time = date(&#8220;Y-m-d H:i:s&#8221;, strtotime($data[&#8216;time&#8217;])); <a href=\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":71,"featured_media":41008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[305,13],"tags":[2071],"class_list":["post-41336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opencart","category-php","tag-opencart"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog<\/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:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Normally we can get local date and time by using php date function but today we will learn to get present time of different time zone. Here is the code $date = new DateTime(&#039;2014-06-1&#039;, new DateTimeZone(&#039;America\/Mexico_City&#039;)); $zone = $date-&gt;format(&#039;P&#039;); $query = &quot;SELECT CONVERT_TZ(NOW(), @@session.time_zone, &#039;$zone&#039;) as time;&quot;; $data = $this-&gt;db-&gt;query($query)-&gt;row; $time = date(&quot;Y-m-d H:i:s&quot;, strtotime($data[&#039;time&#039;])); [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-17T19:03:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-17T12:16:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sambit Pattanayak\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sambit Pattanayak\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\"},\"author\":{\"name\":\"Sambit Pattanayak\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/23309d7bfba5b06d58b50ea5e3191f01\"},\"headline\":\"How To Get Present Time Of Any Time Zone In Opencart\",\"datePublished\":\"2016-02-17T19:03:21+00:00\",\"dateModified\":\"2016-03-17T12:16:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\"},\"wordCount\":41,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"keywords\":[\"opencart\"],\"articleSection\":[\"opencart\",\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\",\"name\":\"How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"datePublished\":\"2016-02-17T19:03:21+00:00\",\"dateModified\":\"2016-03-17T12:16:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Get Present Time Of Any Time Zone In Opencart\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/23309d7bfba5b06d58b50ea5e3191f01\",\"name\":\"Sambit Pattanayak\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b470681418ca47d8211cf413884189c631a12188462ba25500fa51c897318975?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b470681418ca47d8211cf413884189c631a12188462ba25500fa51c897318975?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sambit Pattanayak\"},\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sambit-p819\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog","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:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/","og_locale":"en_US","og_type":"article","og_title":"How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog","og_description":"Normally we can get local date and time by using php date function but today we will learn to get present time of different time zone. Here is the code $date = new DateTime('2014-06-1', new DateTimeZone('America\/Mexico_City')); $zone = $date-&gt;format('P'); $query = \"SELECT CONVERT_TZ(NOW(), @@session.time_zone, '$zone') as time;\"; $data = $this-&gt;db-&gt;query($query)-&gt;row; $time = date(\"Y-m-d H:i:s\", strtotime($data['time'])); [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-02-17T19:03:21+00:00","article_modified_time":"2016-03-17T12:16:50+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","type":"image\/png"}],"author":"Sambit Pattanayak","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sambit Pattanayak","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/"},"author":{"name":"Sambit Pattanayak","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/23309d7bfba5b06d58b50ea5e3191f01"},"headline":"How To Get Present Time Of Any Time Zone In Opencart","datePublished":"2016-02-17T19:03:21+00:00","dateModified":"2016-03-17T12:16:50+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/"},"wordCount":41,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","keywords":["opencart"],"articleSection":["opencart","php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/","url":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/","name":"How To Get Present Time Of Any Time Zone In Opencart - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","datePublished":"2016-02-17T19:03:21+00:00","dateModified":"2016-03-17T12:16:50+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-get-present-time-of-any-time-zone-in-opencart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Get Present Time Of Any Time Zone In Opencart"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/23309d7bfba5b06d58b50ea5e3191f01","name":"Sambit Pattanayak","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b470681418ca47d8211cf413884189c631a12188462ba25500fa51c897318975?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b470681418ca47d8211cf413884189c631a12188462ba25500fa51c897318975?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sambit Pattanayak"},"sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/sambit-p819\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=41336"}],"version-history":[{"count":1,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41336\/revisions"}],"predecessor-version":[{"id":41339,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41336\/revisions\/41339"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/41008"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=41336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=41336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=41336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}