Can anyone help me to change Gregorian date to Persian in JavaScript? I want to use it in HTML and JavaScript.
You can use toLocaleDateString();
let today = new Date().toLocaleDateString('fa-IR');
console.log(today);
fa-IR
is for Farsi-Iran,
other dates is as follow:
en-US
: For English
hi-IN
: For Hindi
...
also you can set options as second argument, for example:
let options = { year: 'numeric', month: 'long', day: 'numeric' };
new Date().toLocaleDateString('fa-IR', options);