<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                `time`?包為我們提供了一個數據類型?`time.Time`(作為值使用)以及顯示和測量時間和日期的功能函數。 當前時間可以使用?`time.Now()`?獲取,或者使用?`t.Day()`、`t.Minute()`?等等來獲取時間的一部分;你甚至可以自定義時間格式化字符串,例如:?`fmt.Printf("%02d.%02d.%4d\n", t.Day(), t.Month(), t.Year())`?將會輸出?`21.07.2011`。 Duration 類型表示兩個連續時刻所相差的納秒數,類型為 int64。Location 類型映射某個時區的時間,UTC 表示通用協調世界時間。 包中的一個預定義函數?`func (t Time) Format(layout string) string`?可以根據一個格式化字符串來將一個時間 t 轉換為相應格式的字符串,你可以使用一些預定義的格式,如:`time.ANSIC`?或?`time.RFC822`。 一般的格式化設計是通過對于一個標準時間的格式化描述來展現的,這聽起來很奇怪,但看下面這個例子你就會一目了然: ~~~ fmt.Println(t.Format("02 Jan 2006 15:04")) ~~~ 輸出: ~~~ 21 Jul 2011 10:31 ~~~ 其它有關時間操作的文檔請參閱?[官方文檔](http://golang.org/pkg/time/)(?**譯者注:國內用戶可訪問?[該頁面](http://docs.studygolang.com/pkg/time/)**?)。 示例 4.20?[time.go](https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/examples/chapter_4/time.go) ~~~ package main import ( "fmt" "time" ) var week time.Duration func main() { t := time.Now() fmt.Println(t) // e.g. Wed Dec 21 09:52:14 +0100 RST 2011 fmt.Printf("%02d.%02d.%4d\n", t.Day(), t.Month(), t.Year()) // 21.12.2011 t = time.Now().UTC() fmt.Println(t) // Wed Dec 21 08:52:14 +0000 UTC 2011 fmt.Println(time.Now()) // Wed Dec 21 09:52:14 +0100 RST 2011 // calculating times: week = 60 * 60 * 24 * 7 * 1e9 // must be in nanosec week_from_now := t.Add(week) fmt.Println(week_from_now) // Wed Dec 28 08:52:14 +0000 UTC 2011 // formatting times: fmt.Println(t.Format(time.RFC822)) // 21 Dec 11 0852 UTC fmt.Println(t.Format(time.ANSIC)) // Wed Dec 21 08:56:34 2011 fmt.Println(t.Format("02 Jan 2006 15:04")) // 21 Dec 2011 08:52 s := t.Format("20060102") fmt.Println(t, "=>", s) // Wed Dec 21 08:52:14 +0000 UTC 2011 => 20111221 } ~~~ 輸出的結果已經寫在每行?`//`?的后面。 如果你需要在應用程序在經過一定時間或周期執行某項任務(事件處理的特例),則可以使用?`time.After`?或者`time.Ticker`:我們將會在第 14.5 節討論這些有趣的事情。 另外,`time.Sleep(Duration d)`?可以實現對某個進程(實質上是 goroutine)時長為 d 的暫停。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看