I am facing some issues with displaying dates. when users select a date i am formatting it like this
new Date(date).toISOString().split('T')[0];
because this is the format our django backend expects and then the backend returns a date like this:
2021-09-02
then I am formatting the date returned from the backend with moment.js:
moment.utc(new Date(date)).format('MMM DD')
But the problem is that when I select "September 25" I get "Sep 25".
But some of my team members who are in India select "September 25" they get "Sep 24".
If I run new Date('2021-09-02')
in my dev tools.
I get Wed Sep 01 2021 17:00:00 GMT-0700 (Pacific Daylight Time)
and they get Date Thu Sep 02 2021 05:30:00 GMT+0530 (India Standard Time)
How can I handle this edge case? I'm not sure if I need to update the format stored on the backend. need your suggestions