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

After converting, the date always comes back one day off #126

Open
darushHamidi opened this issue Jul 3, 2022 · 3 comments
Open

After converting, the date always comes back one day off #126

darushHamidi opened this issue Jul 3, 2022 · 3 comments

Comments

@darushHamidi
Copy link

I convert the Shamsi date to gregorian date with the following snippet:

var m = moment.from('1401/6/1', 'fa', 'YYYY/MM/DD');
const result = m.locale('en').format('YYYY/MM/DD'); // 2022/08/23

Now, the day is 23, After converting the result to the date object the day will get 22, Why?
const date = new Date(result); // 2022-08-22T19:30:00.000Z

@aroshanzamir
Copy link

try this:

const date = moment.from(persianDate, 'fa', 'YYYY/MM/DD').locale('en').format('YYYY/MM/DD').replace(/\//g, '-');
console.log(new Date(date))

@fingerpich
Copy link
Owner

Hi please create a demo for the issues
I have created a demo and seems it works well
https://stackblitz.com/edit/jalali-moment-demo-react-iewto2?file=index.js

@amirhosein993
Copy link

I have the same issue. When converting a gregorian date to persian date. The date comes back !

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

4 participants