format() not corresponding to date.
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
I have the following ISO-formatted string:
`2022-02-28T13:57:02.000Z`
When I do `console.log(dayjs(isoString).tz("Australia/Sydney"))` the date object prints as follows:
```
M {
'$L': 'en',
'$d': 2022-02-28T23:57:02.000Z,
'$x': { '$timezone': 'Australia/Sydney' },
'$y': 2022,
'$M': 2,
'$D': 1,
'$W': 2,
'$H': 0,
'$m': 57,
'$s': 2,
'$ms': 0,
'$offset': 660,
'$u': false
}
```
For my application, I need to get the date that is in the `$d` field, like `2022-02-28`, but when I do `.format("YYYY-MM-DD")` it returns `2022-03-01`
**Expected behavior**
It should return `2022-02-28`
**Information**
- Day.js Version [e.g. v1.10.8]
- OS: [Linux]
- Browser: Node 16
- Time zone: [CET]
Contributor guide
Research direction
No source file or test is named. Reproduce the supplied Node 16 example with the timezone plugin and inspect the timezone and format behavior first. Done means determining whether the observed date mismatch is a formatting defect and adding a focused regression test or documenting the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100