{"id":11338,"date":"2015-05-26T15:09:01","date_gmt":"2015-05-26T19:09:01","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11338"},"modified":"2015-05-28T10:23:18","modified_gmt":"2015-05-28T14:23:18","slug":"predictable-date-formatting","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/05\/26\/predictable-date-formatting\/","title":{"rendered":"Predictable Date Formatting"},"content":{"rendered":"<p><a href=\"http:\/\/indiestack.com\/2015\/05\/predictable-date-formatting\/\">Daniel Jalkut<\/a>:<\/p>\n<blockquote cite=\"http:\/\/indiestack.com\/2015\/05\/predictable-date-formatting\/\">\n<p>That &ldquo;HH&rdquo; is supposed to reflect the hour as a zero-padded number between 00 and 23. And it does, or at least it has, ever since I started using this formatting string in MarsEdit eight years ago.<\/p>\n<p>Starting very recently, I think with 10.10.3, NSDateFormatter may return a string formatted for the user&rsquo;s 12-hour clock preference, and with a troubling &ldquo;am&rdquo; or &ldquo;pm&rdquo; component embedded within.<\/p>\n<\/blockquote>\n<p>I don&rsquo;t think I saw this problem because my date formatters like this were configured to use the &ldquo;en_US&rdquo;&nbsp;locale. However, Jalkut points out that <a href=\"https:\/\/developer.apple.com\/library\/ios\/qa\/qa1480\/_index.html\">even better<\/a> is to use &ldquo;en_US_POSIX&rdquo;.<\/p>\n<p>Update (2015-05-28): <a href=\"https:\/\/twitter.com\/AliRantakari\/status\/603464884781744128\">Ali Rantakari<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/AliRantakari\/status\/603464884781744128\"><p>My @fauxpasapp can help <a href=\"http:\/\/fauxpasapp.com\/rules\/#rule-FixedFormatDateFormatter\">find\/detect cases like this<\/a> and suggests `en_US_POSIX`.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Daniel Jalkut: That &ldquo;HH&rdquo; is supposed to reflect the hour as a zero-padded number between 00 and 23. And it does, or at least it has, ever since I started using this formatting string in MarsEdit eight years ago. Starting very recently, I think with 10.10.3, NSDateFormatter may return a string formatted for the user&rsquo;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[131,69,31,30,568,71],"class_list":["post-11338","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-ios","tag-mac","tag-nsdateformatter","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=11338"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11338\/revisions"}],"predecessor-version":[{"id":11352,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11338\/revisions\/11352"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}