-
Notifications
You must be signed in to change notification settings - Fork 18k
time: In() does not replace the time zone correctly #73480
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
Comments
As @seankhliao mentioned, this is working as intended, thanks for asking the question. 👍 |
Working as intended. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
Go version
go version go1.24.0 linux/arm64
Output of
go env
in your module/workspace:What did you do?
The
time.In()
function documentation states:But it changes the time as well, essentially converting the time to the time zone offset.
Example: https://go.dev/play/p/-s0CkU9VSC7
What did you see happen?
t1
shows the time in UTC that is used as the base time.time.FixedZone
that offsets it -8 hours from UTC (in seconds).t2
time zone with thetime.In()
function.t2
should show2025-04-01 02:15:24 -0800 GMT -8:00
but the time gets offset by -8 hours, showing2025-03-31 18:15:24 -0800 GMT-8
.Is this the expected behavior?
Example: https://go.dev/play/p/-s0CkU9VSC7
What did you expect to see?
If
t1
in the example is2025-04-01 02:15:24 UTC
, thent2
should also show2025-04-01 02:15:24 -0800 GMT -8:00
, switching the time zone only, but not the date/time.The text was updated successfully, but these errors were encountered: