Returning date as an object in system timezone
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
My system time is PST and trying to convert to CST. Here's what we have:
```
dayjs.extend(relativeTime)
dayjs.extend(advancedFormat)
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz.setDefault('America/Chicago')
const timezonedDayjs = (...args: any[]) => dayjs(...args).tz()
export default timezonedDayjs
```
`timezonedDayjs().format()` will return the correct date, time and timezone (good) but in a string (bad)
`timezonedDayjs().toDate()` will return the correct date and time but incorrect timezone (bad) but in an object (good)
Is there any way to have `timezonedDayjs` return the correct timezone (CST) in the correct format (object)?
**Expected behavior**
A clear and concise description of what you expected to happen.
**Information**
- Day.js Version v 1.11.10
- OS: Mac OS 14.5
- Browser Chrome 126.X
- Time zone: GMT-0500 Central Standard Time
Contributor guide
Research direction
The issue names no source file or test. Begin by reproducing the shown utc and timezone plugin setup with dayjs.tz.setDefault('America/Chicago'), then inspect how format() and toDate() represent the same value. Done would require a documented or tested resolution for the requested timezone-aware object behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100