How to change Gregorian date to Persian date in JavaScript?

前端 未结 9 608
青春惊慌失措
青春惊慌失措 2021-02-04 23:46

Can anyone help me to change Gregorian date to Persian in JavaScript? I want to use it in HTML and JavaScript.

9条回答
  •  孤街浪徒
    2021-02-05 00:25

    You can use toLocaleDateString();

    let today = new Date().toLocaleDateString('fa-IR');
    console.log(today);

    fa-IR is for Farsi-Iran,

    other's like bellow:

    en-US: For English

    hi-IN: For Hindi

    ...

提交回复
热议问题