{"id":370,"date":"2019-06-24T21:47:56","date_gmt":"2019-06-25T03:47:56","guid":{"rendered":"http:\/\/n8williams.com\/devblog\/?p=370"},"modified":"2020-11-28T16:02:02","modified_gmt":"2020-11-28T22:02:02","slug":"getting-the-current-date-for-a-timezone-with-elixir","status":"publish","type":"post","link":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir","title":{"rendered":"Getting the current date for a timezone with Elixir"},"content":{"rendered":"\n<p>Issue: Getting the (current or otherwise) date for a specific timezone can be involve some trickiness.<\/p>\n\n\n\n<p>Example: I want to show the current date in New York, even though I reside in Austin, TX. If it is 12\/11\/2020 11:39 PM CT:<\/p>\n\n\n\n<ul><li>The display for NY data should show 12\/12\/2020<\/li><li>A display for Austin, TX would show 12\/11\/20202<\/li><\/ul>\n\n\n\n<p>One solution:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/n8williams\/0a7521d02d4a507d8b9d3956345db184.js\"><\/script>\n\n\n<p>NOTE: When dealing with DateTimes to save to a database, leaving the microseconds on can cause issues. I&#8217;m surprised the DateTime result doesn&#8217;t default to the more compatible format (TBD on whether from Elixir or Timex). See <a href=\"https:\/\/github.com\/riverrun\/phauxth-example\/issues\/10\">https:\/\/github.com\/riverrun\/phauxth-example\/issues\/10<\/a><\/p>\n\n\n<script src=\"https:\/\/gist.github.com\/n8williams\/714c7ca790b19ebeeba8218809e53d92.js\"><\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Issue: Getting the (current or otherwise) date for a specific timezone can be involve some trickiness. Example: I want to show the current date in New York, even though I reside in Austin, TX. If it is 12\/11\/2020 11:39 PM CT: The display for NY data should show 12\/12\/2020 A display for Austin, TX would &hellip; <a href=\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting the current date for a timezone with Elixir&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting the current date for a timezone with Elixir - The Dev Pages<\/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:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting the current date for a timezone with Elixir - The Dev Pages\" \/>\n<meta property=\"og:description\" content=\"Issue: Getting the (current or otherwise) date for a specific timezone can be involve some trickiness. Example: I want to show the current date in New York, even though I reside in Austin, TX. If it is 12\/11\/2020 11:39 PM CT: The display for NY data should show 12\/12\/2020 A display for Austin, TX would &hellip; Continue reading &quot;Getting the current date for a timezone with Elixir&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\" \/>\n<meta property=\"og:site_name\" content=\"The Dev Pages\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-25T03:47:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-28T22:02:02+00:00\" \/>\n<meta name=\"author\" content=\"Nate Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@admin\" \/>\n<meta name=\"twitter:site\" content=\"@admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate Admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#article\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\"},\"author\":{\"name\":\"Nate Admin\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"headline\":\"Getting the current date for a timezone with Elixir\",\"datePublished\":\"2019-06-25T03:47:56+00:00\",\"dateModified\":\"2020-11-28T22:02:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\"},\"wordCount\":107,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"articleSection\":[\"Elixir and Phoenix\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\",\"url\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\",\"name\":\"Getting the current date for a timezone with Elixir - The Dev Pages\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\"},\"datePublished\":\"2019-06-25T03:47:56+00:00\",\"dateModified\":\"2020-11-28T22:02:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/n8williams.com\/devblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting the current date for a timezone with Elixir\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\",\"url\":\"https:\/\/n8williams.com\/devblog\/\",\"name\":\"The Dev Pages\",\"description\":\"A knowledge base for web applications development (and beyond)\",\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/n8williams.com\/devblog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\",\"name\":\"Nate Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"caption\":\"Nate Admin\"},\"logo\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/n8williams.com\",\"https:\/\/twitter.com\/admin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting the current date for a timezone with Elixir - The Dev Pages","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:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir","og_locale":"en_US","og_type":"article","og_title":"Getting the current date for a timezone with Elixir - The Dev Pages","og_description":"Issue: Getting the (current or otherwise) date for a specific timezone can be involve some trickiness. Example: I want to show the current date in New York, even though I reside in Austin, TX. If it is 12\/11\/2020 11:39 PM CT: The display for NY data should show 12\/12\/2020 A display for Austin, TX would &hellip; Continue reading \"Getting the current date for a timezone with Elixir\"","og_url":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir","og_site_name":"The Dev Pages","article_published_time":"2019-06-25T03:47:56+00:00","article_modified_time":"2020-11-28T22:02:02+00:00","author":"Nate Admin","twitter_card":"summary_large_image","twitter_creator":"@admin","twitter_site":"@admin","twitter_misc":{"Written by":"Nate Admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#article","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir"},"author":{"name":"Nate Admin","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"headline":"Getting the current date for a timezone with Elixir","datePublished":"2019-06-25T03:47:56+00:00","dateModified":"2020-11-28T22:02:02+00:00","mainEntityOfPage":{"@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir"},"wordCount":107,"commentCount":0,"publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"articleSection":["Elixir and Phoenix"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#respond"]}]},{"@type":"WebPage","@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir","url":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir","name":"Getting the current date for a timezone with Elixir - The Dev Pages","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/#website"},"datePublished":"2019-06-25T03:47:56+00:00","dateModified":"2020-11-28T22:02:02+00:00","breadcrumb":{"@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/n8williams.com\/devblog\/elixir-and-phoenix\/getting-the-current-date-for-a-timezone-with-elixir#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/n8williams.com\/devblog\/"},{"@type":"ListItem","position":2,"name":"Getting the current date for a timezone with Elixir"}]},{"@type":"WebSite","@id":"https:\/\/n8williams.com\/devblog\/#website","url":"https:\/\/n8williams.com\/devblog\/","name":"The Dev Pages","description":"A knowledge base for web applications development (and beyond)","publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/n8williams.com\/devblog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757","name":"Nate Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","caption":"Nate Admin"},"logo":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/n8williams.com","https:\/\/twitter.com\/admin"]}]}},"_links":{"self":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/370"}],"collection":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/comments?post=370"}],"version-history":[{"count":13,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/370\/revisions"}],"predecessor-version":[{"id":589,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/370\/revisions\/589"}],"wp:attachment":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/media?parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/categories?post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/tags?post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}