time.Time initialized with time.Unix() and time.Parse() with exactly the same unix timestamp gives different results being printed with time.Format("2006-01-02")
The problem is not reproducible in playground, but I get it if I compile it myself.
My default time zone is Los Angeles, probably in different timezone result would be different.
go version go version go1.12.1 darwin/amd64
go build
./test
test.go:
package main
import (
"fmt"
"time"
)
func main() {
control1 := time.Unix(1546300800, 0)
test, _ := time.Parse("2006-01-02", "2019-01-01")
fmt.Println("control:", control1.Unix(), control1.Format("2006-01-02"))
fmt.Println("test:", test.Unix(), test.Format("2006-01-02"))
}
./test control: 1546300800 2018-12-31 test: 1546300800 2019-01-01
So unix ts is the same (1546300800), but dates are different. Why?