首页 > 解决方案 > 如何将波斯数字转换为英文

问题描述

我想获取日期(shamsi 日期),然后将数字转换为英文进行计算。我需要将“现在”转换为英文数字。

    function HTMLUI(){}
    
    //display year
    HTMLUI.prototype.displayYear = function(){
        //get max year
        const now = new Date().toLocaleDateString('fa-IR')
    
        console.log(now.slice(0, 4));
    
    }

标签: javascriptnode.js

解决方案


你的意思是这样吗?

HTMLUI.prototype.displayYear = function(){

    const theYear = new Date().getUTCFullYear().toString();
    
    console.log( theYear );
    
}

推荐阅读