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

Returning date as an object in system timezone #2701

Open
maxfavor opened this issue Jul 25, 2024 · 0 comments
Open

Returning date as an object in system timezone #2701

maxfavor opened this issue Jul 25, 2024 · 0 comments

Comments

@maxfavor
Copy link

maxfavor commented Jul 25, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant