iamkun / iamkun/dayjs

Getting wrong startOf('day') and endOf('day') in a different timezone

Open
#2,467 6 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The functions `startOf('day')` and `endOf('day')` are returning the wrong day when I change the timezone from UTC (GMT).

Code example:

`dayjs('2023-09-01').tz('America/Sao_Paulo').startOf('day')`

Result:
`Thu, 31 Aug 2023 03:00:00 GMT`

**Expected behavior**
`Fri, 01 Sep 2023 03:00:00 GMT`

**Information**
- Day.js Version: ^1.11.3
- OS: Ubuntu 22.04.3 LTS
- Browser: Node JS 16
- Time zone: UTC (GMT)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.