Go time Package LoadLocation()

Description

Go time Package LoadLocation()

package main//from  www.  j a  v a 2s  .co  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))
     
     
}



PreviousNext

Related