Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to change .toLocaleString() digits to english?

I try to change a date from Gregorian date to local date (Jalali). with this code:

document.write(new Date().toLocaleString("fa-IR"))

and it returns: ۱۴۰۱/۱۲/۲۲, ۱۱:۴۲:۰۰

But I need to be return output in English digits, like this: 1401/11/22, 11:42:00

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In toLocaleString the first option is preferred for language, if you want to have an Gregorian date with English digits you should use calendar option such as

console.log(new Date().toLocaleString("en" , {calendar: 'persian'}));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading