time.Format?????

agolangf · · 978 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>What is the significance of the magic strings like &#34;Mon Jan 02 15:04:05 -0700 2006&#34; I don&#39;t understand why they don&#39;t use &#39;H:m:s \m \i\s\ \m\o\n\t\h&#39;</p> <p>i.e why 2006? I would understand 1970....</p> <hr/>**评论:**<br/><br/>garaktailor: <pre><p>01 - Month</p> <p>02 - Day</p> <p>03 - Hour (15: 3pm)</p> <p>04 - Minute</p> <p>05 - Second</p> <p>06 - Year (2006)</p> <p>07 - Timezone Offset</p></pre>garaktailor: <pre><p>I personally like this much better than the traditional way to do date formatting. Without looking, what is the difference between &#39;yyyy&#39; and &#39;YYYY&#39; in java? Twitter used the wrong one and it <a href="https://news.ycombinator.com/item?id=8810157" rel="nofollow">brought down their API a year ago</a>.</p></pre>nohoudini: <pre><p>For some guys in other geographic areas its not obvious that 01 is month, for me day would be more obvious :-) I find the time.Format bad as well but ok ;-) maybe I&#39;m missing something here.</p></pre>qogemma: <pre><p>I just wish they&#39;d put them in some kind of order. How are you supposed to remember that month comes before day and second comes before year?</p></pre>dsymonds: <pre><p>It was an unfortunate accident that is too late to change now. It matches the ANSI C ordering, FWIW.</p></pre>maidenelk: <pre><p>From the <a href="https://github.com/golang/go/blob/f4b4d2f4d9f574fe34b826bf0e6784956a247687/src/time/format.go" rel="nofollow">source</a>:</p> <pre><code>// The reference time used in the layouts is the specific time: // Mon Jan 2 15:04:05 MST 2006 // which is Unix time 1136239445. Since MST is GMT-0700, // the reference time can be thought of as // 01/02 03:04:05PM &#39;06 -0700 </code></pre></pre>twek: <pre><p>That&#39;s what I get for skimming. Thanks!</p></pre>andreynering: <pre><p><a href="http://andrey.nering.com.br/blog/2015/how-to-format-date-and-time-with-go-lang/" rel="nofollow">How to format Date and Time with Go Lang</a></p></pre>f2f: <pre><p>&#34;oh my god, something is not as I expect it. five questionmarks. quick call the whaaaaambulance!&#34;</p> <p>(has the CoC been accepted here yet? i&#39;m fully acknowledging that i&#39;m breaking it :)</p></pre>twek: <pre><p>Ha. Calm down I was just over zealous in my curiosity. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

978 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传