{"id":880,"date":"2023-10-19T09:40:33","date_gmt":"2023-10-19T09:40:33","guid":{"rendered":"https:\/\/www.devopsconsulting.in\/blog\/?p=880"},"modified":"2023-11-07T09:47:51","modified_gmt":"2023-11-07T09:47:51","slug":"convert-utc-time-to-local-time","status":"publish","type":"post","link":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/","title":{"rendered":"Convert UTC Time to Local Time"},"content":{"rendered":"\n<p>I will demonstrate how to use Laravel to convert UTC to local time in this section. We&#8217;ll assist you by providing a sample of how to convert UTC to local time using Laravel Carbon. I gave a brief explanation on how to use Laravel to convert UTC time to local time. I will demonstrate how to use Laravel to convert UTC to local time. So let&#8217;s develop an example of converting UTC to local time in Ruby using a few simple steps.<\/p>\n\n\n\n<p>The Carbon setTimezone() method will be utilized in Laravel to convert UTC time to local time. The setTimezone() function requires you to provide in your local timezone as an input. We shall convert the UTC time in this example to my local time, &#8220;Asia\/Kolkata&#8221;.<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<p>you can see the simple example with custom date and time:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class UserController extends Controller\n{\n    \/**\n     * Display a listing of the resource.\n     *\n     * @return \\Illuminate\\Http\\Response\n     *\/\n    public function index(Request $request)\n    {\n        $time = Carbon::parse('2023-10-18 20:25:48')\n                        -&gt;setTimezone('Asia\/Kolkata')\n                        -&gt;toDateTimeString();\n                          \n        dd($time);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>OutPut:<\/strong><\/p>\n\n\n\n<p>2023-10-19 01:55:48<\/p>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<p>you can see the simple example with now date and time<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n     \nnamespace App\\Http\\Controllers;\n    \nuse Illuminate\\Http\\Request;\nuse Carbon\\Carbon;\n    \nclass UserController extends Controller\n{\n    \/**\n     * Display a listing of the resource.\n     *\n     * @return \\Illuminate\\Http\\Response\n     *\/\n    public function index(Request $request)\n    {\n        $time = Carbon::now()\n                    -&gt;setTimezone('Asia\/Kolkata')\n                    -&gt;toDateTimeString();\n  \n        dd($time);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>OutPut:<\/strong><\/p>\n\n\n\n<p>2023-10-19 09:23:56<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will demonstrate how to use Laravel to convert UTC to local time in this section. We&#8217;ll assist you by providing a sample of how to convert&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87],"tags":[],"class_list":["post-880","post","type-post","status-publish","format-standard","hentry","category-laravel"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert UTC Time to Local Time - DevOps Consulting<\/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:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert UTC Time to Local Time - DevOps Consulting\" \/>\n<meta property=\"og:description\" content=\"I will demonstrate how to use Laravel to convert UTC to local time in this section. We&#8217;ll assist you by providing a sample of how to convert...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps Consulting\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-19T09:40:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-07T09:47:51+00:00\" \/>\n<meta name=\"author\" content=\"Abhishek Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Singh\" \/>\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:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/\"},\"author\":{\"name\":\"Abhishek Singh\",\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/#\\\/schema\\\/person\\\/fc397ba8be42f9fdd53450edfc73006f\"},\"headline\":\"Convert UTC Time to Local Time\",\"datePublished\":\"2023-10-19T09:40:33+00:00\",\"dateModified\":\"2023-11-07T09:47:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/\"},\"wordCount\":165,\"commentCount\":1,\"articleSection\":[\"Laravel\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/\",\"url\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/\",\"name\":\"Convert UTC Time to Local Time - DevOps Consulting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/#website\"},\"datePublished\":\"2023-10-19T09:40:33+00:00\",\"dateModified\":\"2023-11-07T09:47:51+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/#\\\/schema\\\/person\\\/fc397ba8be42f9fdd53450edfc73006f\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/convert-utc-time-to-local-time\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/\",\"name\":\"DevOps Consulting\",\"description\":\"DevOps Consulting | SRE Consulting | DevSecOps Consulting | MLOps Consulting\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/#\\\/schema\\\/person\\\/fc397ba8be42f9fdd53450edfc73006f\",\"name\":\"Abhishek Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g\",\"caption\":\"Abhishek Singh\"},\"description\":\"I\u2019m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I\u2019ve had the opportunity to work with Cotocus and continue to contribute to multiple platforms where I share insights across different domains: \u2022 DevOps School \u2013 Tech blogs and tutorials \u2022 Holiday Landmark \u2013 Travel stories and guides \u2022 Stocks Mantra \u2013 Stock market strategies and tips \u2022 My Medic Plus \u2013 Health and fitness guidance \u2022 TrueReviewNow \u2013 Honest product reviews \u2022 Wizbrand \u2013 SEO and digital tools for businesses I\u2019m also exploring the fascinating world of Quantum Computing.\",\"url\":\"https:\\\/\\\/www.devopsconsulting.in\\\/blog\\\/author\\\/abhishek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convert UTC Time to Local Time - DevOps Consulting","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:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/","og_locale":"en_US","og_type":"article","og_title":"Convert UTC Time to Local Time - DevOps Consulting","og_description":"I will demonstrate how to use Laravel to convert UTC to local time in this section. We&#8217;ll assist you by providing a sample of how to convert...","og_url":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/","og_site_name":"DevOps Consulting","article_published_time":"2023-10-19T09:40:33+00:00","article_modified_time":"2023-11-07T09:47:51+00:00","author":"Abhishek Singh","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abhishek Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/#article","isPartOf":{"@id":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/"},"author":{"name":"Abhishek Singh","@id":"https:\/\/www.devopsconsulting.in\/blog\/#\/schema\/person\/fc397ba8be42f9fdd53450edfc73006f"},"headline":"Convert UTC Time to Local Time","datePublished":"2023-10-19T09:40:33+00:00","dateModified":"2023-11-07T09:47:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/"},"wordCount":165,"commentCount":1,"articleSection":["Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/","url":"https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/","name":"Convert UTC Time to Local Time - DevOps Consulting","isPartOf":{"@id":"https:\/\/www.devopsconsulting.in\/blog\/#website"},"datePublished":"2023-10-19T09:40:33+00:00","dateModified":"2023-11-07T09:47:51+00:00","author":{"@id":"https:\/\/www.devopsconsulting.in\/blog\/#\/schema\/person\/fc397ba8be42f9fdd53450edfc73006f"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopsconsulting.in\/blog\/convert-utc-time-to-local-time\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.devopsconsulting.in\/blog\/#website","url":"https:\/\/www.devopsconsulting.in\/blog\/","name":"DevOps Consulting","description":"DevOps Consulting | SRE Consulting | DevSecOps Consulting | MLOps Consulting","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopsconsulting.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopsconsulting.in\/blog\/#\/schema\/person\/fc397ba8be42f9fdd53450edfc73006f","name":"Abhishek Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/790feefe779852cdf344ca7318bf6c13832223c9b3c6bf4d217658412041026d?s=96&d=mm&r=g","caption":"Abhishek Singh"},"description":"I\u2019m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I\u2019ve had the opportunity to work with Cotocus and continue to contribute to multiple platforms where I share insights across different domains: \u2022 DevOps School \u2013 Tech blogs and tutorials \u2022 Holiday Landmark \u2013 Travel stories and guides \u2022 Stocks Mantra \u2013 Stock market strategies and tips \u2022 My Medic Plus \u2013 Health and fitness guidance \u2022 TrueReviewNow \u2013 Honest product reviews \u2022 Wizbrand \u2013 SEO and digital tools for businesses I\u2019m also exploring the fascinating world of Quantum Computing.","url":"https:\/\/www.devopsconsulting.in\/blog\/author\/abhishek\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/posts\/880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/comments?post=880"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/posts\/880\/revisions"}],"predecessor-version":[{"id":884,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/posts\/880\/revisions\/884"}],"wp:attachment":[{"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/media?parent=880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/categories?post=880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsconsulting.in\/blog\/wp-json\/wp\/v2\/tags?post=880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}