Go time Package Parse()

Description

Go time Package Parse()

package main/*from   ww  w  . j  a va 2s.  c o  m*/
 
import (
    "fmt"
    "time"
)
 
func main() {
    t, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(t)
 
    loc, err := time.LoadLocation("America/Los_Angeles")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(loc)
     
    t = t.In(loc)
    fmt.Println(t.Format(time.RFC822))
     
     
}



Previous

Related