Skip to content

Instantly share code, notes, and snippets.

@178inaba
Last active November 4, 2016 09:24
Show Gist options
  • Select an option

  • Save 178inaba/857405a1b992b4bb56cff72bf75ee8ab to your computer and use it in GitHub Desktop.

Select an option

Save 178inaba/857405a1b992b4bb56cff72bf75ee8ab to your computer and use it in GitHub Desktop.

golang timezone test

Build

$ GOOS=linux GOARCH=amd64 go build -v -o tz
$ docker build -t 178inaba/go-tz .

Run

$ docker run -it 178inaba/go-tz
FROM alpine
COPY tz .
CMD ["sh"]
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(time.Now())
fmt.Println(time.Now().Zone())
// Not work in the alpine.
//local, err := time.LoadLocation("Asia/Tokyo")
//if err != nil {
// fmt.Println(err)
//}
local := time.FixedZone("Asia/Tokyo", 9*60*60)
time.Local = local
fmt.Println(time.Local)
fmt.Println(time.Now())
fmt.Println(time.Now().Zone())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment