Reactjs 得到太阳年的反应

Reactjs 得到太阳年的反应,reactjs,date,getdate,jalali-calendar,solar,Reactjs,Date,Getdate,Jalali Calendar,Solar,如何在react中获取当前的太阳年本地fa(非完整日期) 我只需要得到太阳年(jalali),我正在使用这个: new Date().toLocaleDateString('fa-IR'); 但它返回当前日期(1399年4月24日)。我只想要(1399)您可以传递其他选项,并根据需要转换输出 new Date().toLocaleDateString('fa-IR', {year: 'numeric'} ); 您可以传递其他选项,并根据需要变换输出 new Date().toLocaleDa

如何在react中获取当前的太阳年本地fa(非完整日期)

我只需要得到太阳年(jalali),我正在使用这个:

new Date().toLocaleDateString('fa-IR');

但它返回当前日期(1399年4月24日)。我只想要(1399)

您可以传递其他选项,并根据需要转换输出

new Date().toLocaleDateString('fa-IR', {year: 'numeric'} );

您可以传递其他选项,并根据需要变换输出

new Date().toLocaleDateString('fa-IR', {year: 'numeric'} );
我发现了。 答案是:

new Date().toLocaleDateString("fa-IR", {year: "numeric" });
上面的代码返回1399。(当前的贾拉里年(波斯日期))

我发现。 答案是:

new Date().toLocaleDateString("fa-IR", {year: "numeric" });

上面的代码返回1399。(当前的贾拉里年(波斯日期))

我已经将其用于英语版本。我需要在我的项目的FA版本中使用太阳年。我能得到太阳全年吗?或者把公历转换成太阳历?公历就是太阳历。看起来要么这个例子不正确,应该是2020年,要么你想要一个不同的日历。我不需要2020年。我需要LocaleDate(fa),即1399。实际上,我的问题是如何获得1399?我已经将其用于EN版本。我需要在我的项目的FA版本中使用太阳年。我能得到太阳全年吗?或者把公历转换成太阳历?公历就是太阳历。看起来要么这个例子不正确,应该是2020年,要么你想要一个不同的日历。我不需要2020年。我需要LocaleDate(fa),即1399。实际上,我的问题是如何获得1399?