reactjsdategetdatejalali-calendarsolar

get solar year in react


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)


Solution

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

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