Reputation: 3510
I am in the process of moving 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 @ 12:30AM. Meaning it is still the 21st in Los Angeles.
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
I've reviewed the dayjs docs and don't see where I am going wrong. Or perhaps this isn't possible with dayjs?
Upvotes: 0
Views: 21