0

how can I get current solar year local fa (not full date) in react?

I just need to get solar year (jalali) and I'm using this:

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

but it return current date (24/04/1399). I just want (1399)

Zahra Talebi
  • 675
  • 4
  • 11
  • 26

3 Answers3

3

You can pass additional options, and transform output as you want

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

I find that. the answer is :

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

the above code return 1399. (current jalali year (persian date))

Zahra Talebi
  • 675
  • 4
  • 11
  • 26
0
new Date().getFullYear(); // 2020
Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82
  • I've used that for EN version. I need Solar Year to use in FA version of my project. haw can I get Solar Full Year or convert Gregorian to Solar? – Zahra Talebi Jul 14 '20 at 11:02
  • The Gregorian calendar is a solar calendar. It seems like either the example is incorrect and should be 2020, or you want a different calendar. – Nick McCurdy Jul 14 '20 at 11:04
  • I don't need 2020. I need LocaleDate(fa) that is 1399. actually my question was how can I get 1399? – Zahra Talebi Jul 14 '20 at 11:08