{"id":10006928,"date":"2022-11-28T16:48:52","date_gmt":"2022-11-28T08:48:52","guid":{"rendered":"https:\/\/ityet.com\/?p=10006928"},"modified":"2022-11-28T16:48:52","modified_gmt":"2022-11-28T08:48:52","slug":"go-%e5%87%ad%e4%bb%80%e4%b9%88%e6%90%9e%e7%89%b9%e6%ae%8a%ef%bc%9f%e4%b8%8d%e7%94%a8-yyyy-mm-dd%ef%bc%8c%e9%9d%9e%e5%be%97%e8%a6%81-2006-01-02-150405%e3%80%82%e3%80%82%e3%80%82","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006928","title":{"rendered":"Go \u51ed\u4ec0\u4e48\u641e\u7279\u6b8a\uff1f\u4e0d\u7528 yyyy-mm-dd\uff0c\u975e\u5f97\u8981 2006-01-02 15:04:05\u3002\u3002\u3002"},"content":{"rendered":"<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u714e\u9c7c\u3002<\/p>\n<p>\u524d\u6bb5\u65f6\u95f4\u6211\u5199\u4e86\u4e00\u7bc7\u300aGo1.20 \u4e2d\u4e24\u4e2a\u5173\u4e8e Time \u7684\u66f4\u65b0\uff0c\u7ec8\u4e8e\u4e0d\u7528\u80cc 2006-01-02 15:04:05 \u4e86\uff01\u300b\uff0c\u6587\u4e2d\u6709\u63d0\u5230 Go \u7684\u53c2\u8003\u65f6\u95f4\u683c\u5f0f\u662f\uff1a2006-01-02 15:04:05\uff0c\u5e76\u89e3\u91ca\u8fd9\u4e48\u8bbe\u8ba1\u7684\u7f18\u7531\u3002<\/p>\n<p>\u6709\u5f88\u591a\u540c\u5b66\u8868\u793a\u4e0d\u89e3\u3002\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042915535\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u751a\u81f3\u6211\u5728\u70b9\u5916\u5356\u65f6\u8fd8\u7279\u610f\u770b\u4e86\uff0c\u67d0\u56e2\u5728\u4e2a\u4eba\u4fe1\u606f\u9875\u4e2d\u7684\u751f\u65e5\u90a3\u4e00\u680f\uff0c\u662f\u5982\u6b64\u663e\u793a\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042915536\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u90a3\u719f\u6089\u7684 yyyy-mm-dd\u3002\u6211\u751a\u81f3\u4e00\u5ea6\u6000\u7591\u8fd9\u662f\u4e0d\u662f BUG\uff0c\u8fd9\u53ef\u80fd\u53ea\u6709\u7a0b\u5e8f\u5458\u61c2\uff1f<\/p>\n<h2>ISO 8601 \u89c4\u8303<\/h2>\n<p>\u5c24\u5176\u662f\u6709\u63d0\u5230 ISO 8601\uff0c\u8fd9\u662f\u4e00\u4e2a\u56fd\u9645\u6807\u51c6\u5316\u7ec4\u7ec7\u63d0\u4f9b\u7684\u4e00\u4e2a\u6709\u5173\u65f6\u95f4\u8868\u793a\u7684\u89c4\u8303\uff0c\u5176\u4e2d\u6211\u4eec\u6700\u4e3a\u719f\u6089\u7684\u662f\u65e5\u671f\u8868\u793a\u6cd5\u3002<\/p>\n<p>\u5177\u4f53\u4ecb\u7ecd\u6458\u6284\u81ea\u7f51\u7edc\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code>YYYY-MM-DDThh:mm:ss[.mmm]TZD\n2022-11-18T10:05:45+08:00<\/code><\/pre>\n<ul>\n<li>YYYY\uff1a\u56db\u4f4d\u6570\u5e74\u4efd\uff0c\u4e0d\u5168\u8865\u9f50\u3002<\/li>\n<li>MM\uff1a\u6708\u4efd\u3001\u4e24\u4f4d\uff0c\u4e0d\u5168\u8865\u9f50\u3002<\/li>\n<li>DD\uff1a\u4e24\u4f4d\u6570\u7684\u5929(day of the month)\uff0c01~31\u3002<\/li>\n<li>T\uff1a\u6307\u793a\u65f6\u95f4\u5143\u7d20\u7684\u5f00\u59cb\u5b57\u7b26\u3002<\/li>\n<li>hh\uff1a\u4e24\u4f4d\u6570\u7684\u5c0f\u65f6\uff0c00~23\u3002<\/li>\n<li>mm\uff1a\u4e24\u4f4d\u6570\u7684\u5206\u949f\uff0c00~59\u3002<\/li>\n<li>ss\uff1a\u4e24\u4f4d\u6570\u7684\u79d2\uff0c00~59\u3002<\/li>\n<li>mmm\uff1a\u4e09\u4f4d\u6570\u7684\u6beb\u79d2\uff0c000~999\u3002<\/li>\n<li>TZD\uff1a\u65f6\u533a\u6307\u793a\u7b26\uff1aZ \u6216 +hh:mm \u6216 -hh:mm\uff0c+ \u6216 &#8211; \u8868\u793a\u65f6\u533a\u8ddd\u79bb UTC \u65f6\u533a\u591a\u4e45\u3002<\/li>\n<\/ul>\n<h2>\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u7279\u522b<\/h2>\n<p>\u6211\u4eec\u4e4b\u524d\u7684\u6587\u7ae0\u90fd\u5728\u4ecb\u7ecd 2006-01-02 15:04:05 \u8fd9\u4e2a\u65f6\u95f4\u70b9\u4ee3\u8868\u7684\u542b\u4e49\u662f\u4ec0\u4e48\uff0c\u4ee3\u8868\u4ec0\u4e48\u610f\u601d\uff1a<\/p>\n<pre><code>Jan 2 15:04:05 2006 MST\n1   2  3  4  5    6  -7<\/code><\/pre>\n<p>\u8fd9\u6709\u4e00\u4e2a\u5927\u5927\u7684\u95ee\u9898\uff0c\u90a3\u5c31\u662f Go \u4e3a\u4ec0\u4e48\u4e0d\u9075\u5b88 ISO 8601 \u89c4\u8303\uff0c\u975e\u5f97\u7528\u8fd9\u4e2a\uff1f\u8fd9\u83ab\u975e\u662f\u4e00\u79cd\u65b0\u7684\u521b\u65b0&#8230;<\/p>\n<p>\u5728\u6211\u731b\u7ffb\u540e\uff0c\u627e\u5230\u4e86\u5728\u5bf9\u6807\u51c6\u5316\u8fa9\u89e3\u7684\u80cc\u540e\u3002\u5b9e\u9645\u4e0a @Rob Pike \u5728 2014 \u5e74\u5728\u300a<a href=\"https:\/\/link.segmentfault.com\/?enc=jcdiOqPPZEoPRzS%2F3THAVg%3D%3D.IOrTxHLD%2Flu5MQQAV%2F3JmGZHemum1quYJnxXMugzIMyRJwGUsjU2zjHev8XiF3xfzd70%2Fuph1FFyQlneuvTFi8KtoZUk2qpTb2HWyyD560I%3D\" rel=\"nofollow\" title=\"What is the reason behind time.Parse using a reference time?\">What is the reason behind time.Parse using a reference time?<\/a>\u300b\u8fdb\u884c\u4e86\u89e3\u91ca\uff0c\u8bf4\u660e\u4e3a\u4ec0\u4e48\u4f1a\u9009\u62e9\u8fd9\u4e2a\u65f6\u95f4\u70b9\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042915537\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u201c<strong>\u8fd9\u4e2a\u9009\u62e9\u662f\u7531\u6211\u7684 Unix \u673a\u5668\u4e0a\u7684 date \u547d\u4ee4\u7684\u8f93\u51fa\u6240\u51b3\u5b9a\u7684<\/strong>\u3002\u6211\u5e94\u8be5\u610f\u8bc6\u5230\u683c\u5f0f\u4f1a\u968f\u7740\u5730\u533a\u7684\u4e0d\u540c\u800c\u53d8\u5316\u3002\u9519\u4e86\u3002\u4f46\u6211\u4ecd\u7136\u53ef\u4ee5\u8bf4\u5b83\u5f88\u5bb9\u6613\u8bb0\u4f4f\uff0c\u5e76\u4e14\u6709\u636e\u53ef\u67e5\u3002\u201d<\/p>\n<p>\u8fd9\u5c31\u662f\u539f\u56e0\u3002<\/p>\n<h2>\u4e3a\u4ec0\u4e48\u90a3\u4e48\u96be\u53d7<\/h2>\n<p>\u5927\u5bb6\u4e00\u5f00\u59cb\u53ef\u80fd\u4ee5\u4e3a\u53ea\u6709\u6211\u4eec\u7528\u7684\u6bd4\u8f83\u53d8\u626d\uff1f\u4f46\u5176\u5b9e\u4e0d\u6b62\uff0c\u5404\u5730\u7684\u4eba\u90fd\u62e5\u5230\u4e86\u793e\u533a\u91cc\u53cd\u9988\u8fc7\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u5f52\u6839\u5230\u5e95\u8fd8\u662f\u4e16\u754c\u5404\u5730\u7528\u7684\u65f6\u95f4\u683c\u5f0f\u4e0d\u4e00\u6837\uff0c\u800c Go \u8fd9\u91cc\u6839\u636e Rob \u7684\u53cd\u9988\uff0c\u5b9e\u9645\u4e0a\u5b83\u53ea\u662f\u4ee5\u67d0\u56fd\u4e3a\u65f6\u95f4\u4e2d\u5fc3\u7684 \u201c\u968f\u673a\u201d \u683c\u5f0f\uff0c\u5bf9\u5e94\u7684\u5c31\u662f \u201c1 2 3 4 5 6 7\u201d\u3002<\/p>\n<p>\u4f8b\u5982\uff1a\u201cJan 2 3:04 pm 06 -0700\u201d\u3002<\/p>\n<p>\u6240\u4ee3\u8868\u7684\u610f\u4e49\uff1a<\/p>\n<ul>\n<li>Jan\uff1a\u7b2c\u4e00\u4e2a\u6708<\/li>\n<li>2\uff1a\u7b2c\u4e8c\u5929<\/li>\n<li>3\uff1a\u4e0b\u5348 3 \u70b9<\/li>\n<li>4\uff1a\u7b2c 4 \u5206\u949f<\/li>\n<li>5\uff1a\u7b2c 5 \u79d2<\/li>\n<li>6\uff1a\u672c\u4e16\u7eaa\u7b2c 6 \u5e74<\/li>\n<li>7\uff1a\u6bd4\u683c\u6797\u5a01\u6cbb\u6807\u51c6\u65f6\u95f4\u665a 7 \u5c0f\u65f6\u3002<\/li>\n<\/ul>\n<p>\u770b\u8d77\u6765\u5f88\u6709\u89c4\u5f8b\uff0c\u4f46&#8230;<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>Go \u7684\u8fd9\u4e00\u9879\u65f6\u95f4\u89c4\u8303\u9009\u62e9\uff0c\u662f\u6bd4\u8f83\u7279\u6b8a\u7684\u3002\u5f88\u591a\u540c\u5b66\u5e0c\u671b\u4ed6 \u201c\u6539\u90aa\u5f52\u6b63\u201d\uff0c\u7528\u56de YYYY-MM-DD\uff0c\u522b\u518d\u7528 2006-01-02 15:04:05 \u4e86\u3002<\/p>\n<p>\u8fd9\u663e\u7136\u4e0d\u73b0\u5b9e\uff0c\u9996\u5148\u662f Go1 \u517c\u5bb9\u6027\u4e0d\u5141\u8bb8\uff0c\u5176\u6b21\u4e00\u5c71\u4e0d\u80fd\u5bb9\u4e8c\u864e\uff0c\u52a0\u4f30\u8ba1\u90fd\u6ca1\u6cd5\u52a0\u3002\u8fd9\u4ef6\u4e8b\u5df2\u6210\u5b9a\u5c40\u3002<\/p>\n<p>\u5efa\u8bae\u8fd8\u662f\u8bb0\u597d Go1.20 \u8981\u65b0\u589e\u7684 3 \u4e2a\u5e38\u91cf\uff0c\u8fd9\u4e2a\u4ee5\u540e\u4e0d\u7528\u53bb\u80cc\u548c\u67e5\u4e86\u3002\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"go\">DateTime   = &quot;2006-01-02 15:04:05&quot;\nDateOnly   = &quot;2006-01-02&quot;\nTimeOnly   = &quot;15:04:05&quot;<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6bd4\u8f83\u73b0\u5b9e\u3002<\/p>\n<p>\u8fd9\u4e2a\u8bbe\u8ba1\uff0c\u6211\u8ba4\u4e3a\u662f\u6280\u672f\u503a\u52a1\u4e86\u3002\u5c06\u4f1a\u6301\u7eed\u966a\u4f34 Go1 \u7ec8\u8eab\uff0c\u4f60\u6211\u7686\u4e3a\u5c40\u4e2d\u4eba\u3002<\/p>\n<p>Go2 \u6709\u620f\u5417\uff1f\u6682\u672a\u770b\u5230\u3002<\/p>\n<h4>\u63a8\u8350\u9605\u8bfb<\/h4>\n<ul>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=YcA4hohQ3ijbALpQjrXC1A%3D%3D.duzJA1DciYjnIPUlM%2B%2F%2FSS6TC79rIFqOv5C3EGDpZJY%2FmSXCt5x9qTsme%2FE7LIJybrQD%2BU0q9rr%2Br5tIf4s4lg%3D%3D\" rel=\"nofollow\">Go1.20 \u4e2d\u4e24\u4e2a\u5173\u4e8e Time \u7684\u66f4\u65b0\uff0c\u7ec8\u4e8e\u4e0d\u7528\u80cc 2006-01-02 15:04:05 \u4e86\uff01<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=JYQMUd319YoK6HkrRNYEWA%3D%3D.9LIFJIl1CRems2JXSvOKfEIF325JFDNYmXD48REt5SijH5ghzqKhyiNDbFrZXDuwYC75TY9Gex4RZWN79BU7cA%3D%3D\" rel=\"nofollow\">\u6253\u8138\u4e86\u5144\u5f1f\u4eec\uff0cGo1.20 arena \u6765\u4e86\uff01<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=aXVRZ4hBBkGRfWN%2BGPONoQ%3D%3D.mc4GUx3SrZKbxX3fiuRHhM1sWDt4s%2B0HyPivQOWstbk4lUmKDSzYFH7FSJGVHhRKUBwnYQqT23F3nKd5UWp3iQ%3D%3D\" rel=\"nofollow\">Go \u5341\u5e74\u4e86\uff0c\u7ec8\u4e8e\u60f3\u8d77\u8981\u7edf\u4e00 log \u5e93\u4e86\uff01<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042915533\">https:\/\/segmentfault.com\/a\/1190000042915533<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u714e\u9c7c\u3002 \u524d\u6bb5\u65f6\u95f4\u6211\u5199\u4e86\u4e00\u7bc7\u300aGo1.20 \u4e2d\u4e24\u4e2a\u5173\u4e8e Time \u7684\u66f4\u65b0\uff0c\u7ec8\u4e8e\u4e0d\u7528\u80cc 2006-01 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10006928","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006928"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006928\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}