Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time error? #41270

owenzhou opened this issue Sep 8, 2020 · 2 comments

Time error? #41270

owenzhou opened this issue Sep 8, 2020 · 2 comments


Copy link

@owenzhou owenzhou commented Sep 8, 2020

Time error?

package main


func main(){
	timeLayout := "2006-01-02 15:04:05"

	t := "1990-08-17 13:14:15"

	t2 := "2000-08-17 13:14:15"

	loc, _ := time.LoadLocation("Asia/Shanghai")

	stamp, _ := time.ParseInLocation(timeLayout, t, loc)

	stamp2, _ := time.ParseInLocation(timeLayout, t2, loc)

	fmt.Println( "Datetime:", time.Unix(stamp.Unix(), 0) )

	fmt.Println( "Datetime:", time.Unix(stamp2.Unix(), 0) )


  • Datetime: 1990-08-17 12:14:15 +0800 CST
    Datetime: 2000-08-17 13:14:15 +0800 CST

Why is there an hour difference?

Copy link

@cespare cespare commented Sep 8, 2020

The reason is that Daylight Savings Time was observed in China between 1986 and 1991.

I'm going to close this issue since it doesn't appear to be a bug in Go. Please use if you have further questions. Thanks.

@cespare cespare closed this Sep 8, 2020
Copy link

@owenzhou owenzhou commented Sep 8, 2020

Oh, Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.