这个时间格式是指在Go语言中使用time.Now().UTC().Format(“0102150405”)时的格式。

huangapple go评论101阅读模式
英文:

what this time format in golang time.Now().UTC().Format("0102150405")

问题

我看到代码中的时间格式是"0102150405",但我不知道这是什么格式。有人知道吗? 😊

time.Now().UTC().Format("0102150405")
英文:

I saw the time format "0102150405" in the code, but I don't know what's the format is, Does anyone have an idea about it? 😂

time.Now().UTC().Format("0102150405")

答案1

得分: 4

(2006年1月2日15:04:05,格林尼治标准时间西七小时)。

该值被记录为名为Layout的常量,如下所示。

作为Unix时间,这是1136239445。由于MST是GMT-0700,
Unix date命令将打印出参考时间:
星期一,2006年1月2日15:04:05 MST

您可以使用它来格式化您获得的time值。

0102150405表示想要将time.Now()格式化为类似于"${month}${day}${hour}${minute}${second}"string

> 下面是布局字符串的组成部分的摘要。每个元素都以参考时间元素的格式化示例显示。只有这些值会被识别。在布局字符串中,未被识别为参考时间的文本在格式化期间会被原样输出,并且预计在解析输入时也会原样出现。
>
> 年份:"2006" "06"
>
> 月份:"Jan" "January" "01" "1"
>
> 星期几:"Mon" "Monday"
>
> 月份中的日期:"2" "_2" "02"
>
> 年份中的天数:"__2" "002"
>
> 小时:"15" "3" "03"(下午或上午)
>
> 分钟:"4" "04"
>
> 秒钟:"5" "05"
>
> 上午/下午标记:"PM"

更多信息:


<details>
<summary>英文:</summary>

(January 2, 15:04:05, 2006, in time zone seven hours west of GMT).

That value is recorded as the constant named Layout, listed below.

As a Unix time, this is 1136239445. Since MST is GMT-0700,
the reference would be printed by the Unix date command as:
Mon Jan 2 15:04:05 MST 2006


You can use it to format the `time` value you got.

`0102150405` means want to format `time.Now()` as `string` like `&quot;${month}${day}${hour}${minute}${second}&quot;`.

&gt; Here is a summary of the components of a layout string. Each element shows by example the formatting of an element of the reference time. Only these values are recognized. Text in the layout string that is not recognized as part of the reference time is echoed verbatim during Format and expected to appear verbatim in the input to Parse.
&gt;
&gt; Year: &quot;2006&quot; &quot;06&quot;
&gt;
&gt; Month: &quot;Jan&quot; &quot;January&quot; &quot;01&quot; &quot;1&quot;
&gt;
&gt; Day of the week: &quot;Mon&quot; &quot;Monday&quot;
&gt;
&gt; Day of the month: &quot;2&quot; &quot;_2&quot; &quot;02&quot;
&gt;
&gt; Day of the year: &quot;__2&quot; &quot;002&quot;
&gt;
&gt; Hour: &quot;15&quot; &quot;3&quot; &quot;03&quot; (PM or AM)
&gt;
&gt; Minute: &quot;4&quot; &quot;04&quot;
&gt;
&gt; Second: &quot;5&quot; &quot;05&quot;
&gt;
&gt; AM/PM mark: &quot;PM&quot;


See more: 

- https://pkg.go.dev/time#pkg-constants
- https://pkg.go.dev/time#Time.Format

</details>



huangapple
  • 本文由 发表于 2022年9月2日 18:53:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/73581472.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定