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

Unexpected parsing results when using timezone - migrating from moment.js to dayjs.js #2755

Open
morrow95 opened this issue Oct 22, 2024 · 0 comments

Comments

@morrow95
Copy link

I am in the process of migrating from moment.js to dayjs.js. I am getting unexpected results in a particular use case.

My device is currently using 'America/New_York' timezone and it is ~ 10/22/2024 @ 1:00AM. Meaning it is still the 21st in Los Angeles (3 hours behind me).

moment.js :

dateTZ = 'America/Los_Angeles';     
date = moment().tz(dateTZ).startOf('day').format('MMM Do, YYYY [@] h:mm a z');  
console.log(date); // returns 'Oct 21st, 2024 @ 12:00 am PDT' - correct

dayjs.js :

dateTZ = 'America/Los_Angeles'; 
date = dayjs().tz(dateTZ).startOf('day').format('MMM Do, YYYY [@] h:mm a z');   
console.log(date); // returns 'Oct 21st, 2024 @ 6:00 am PDT' - wrong

Is there a different way to go about getting the result I am looking for with dayjs or is this just not possible with dayjs?

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