How to change Gregorian date to Persian date in JavaScript?

前端 未结 9 611
青春惊慌失措
青春惊慌失措 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:16

    function convertDate(stringArg) {
      const ETF = '۰۱۲۳۴۵۶۷۸۹';
      const ans = g2j(...stringArg.split('/').map(elem => +elem))
        .map(elem =>
          String(elem)
            .split('')
            .map(subElem => ETF[+subElem])
            .join('')
        )
        .join('/');
      return ans;
    }
    

提交回复
热议问题