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

Timezone issue daylight saving and StartOfMonth #192

Closed
oneart-dev opened this issue Oct 30, 2023 · 4 comments
Closed

Timezone issue daylight saving and StartOfMonth #192

oneart-dev opened this issue Oct 30, 2023 · 4 comments
Labels
Bug Report a reproducible bug or regression

Comments

@oneart-dev
Copy link

Hello,

I encountered an issue with the following code:

carbon.Now("Europe/Kiev").StartOfMonth().TimestampMilli()

golang version: go version go1.21.3 darwin/arm64

carbon version: v2.2.0

time zone: -

I expected to get:

1696111200000

But I actually get: 1 hour less

1696107600000

But this solution works just fine:

timezone := "Europe/Kiev"
loc, _ := time.LoadLocation(timezone)
_, tzOffset := time.Now().In(loc).Zone()
carbon.Now().SetTimezone("UTC").StartOfMonth().TimestampMilli() + int64(tzOffset)*-1000

Thanks!

@oneart-dev oneart-dev added the Bug Report a reproducible bug or regression label Oct 30, 2023
@gouguoyin
Copy link
Member

gouguoyin commented Oct 31, 2023

carbon.Now("Europe/Kiev")  = ?

What is the current time here?

@gouguoyin
Copy link
Member

gouguoyin commented Oct 31, 2023

@oneart-dev
Copy link
Author

carbon.Now("Europe/Kiev")  = ?

What is the current time here?

Fastest way to check: https://www.google.com/search?q=time+kiev

https://go.dev/play/p/k8moI-KdDkk

Idk why its wrong. But it is wrong by 1 hour. Any idea why?

@gouguoyin
Copy link
Member

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report a reproducible bug or regression
Development

No branches or pull requests

2 participants