ramadhan hijriah year javascript code example

Example: ramadhan hijriah year javascript

function dynamicHijriyahYear() {
  let yearHijriyah = 1422;
  let initializeHijriyah = 1422;
  let yearsHijriyah = [yearHijriyah];

  let yearNow = new Date().getFullYear();

  for (let i = 0; i < 9999; i++) {
    initializeHijriyah = initializeHijriyah + 1;
    yearsHijriyah.push(initializeHijriyah);
  }

  const getIndexHijriyah = yearsHijriyah.indexOf(yearHijriyah);
  const getSubstractYearHijriyah = Math.abs(
    yearsHijriyah[getIndexHijriyah] - yearNow
  );
  const getYearHijriyah = Math.abs(getSubstractYearHijriyah - yearNow);
  return getYearHijriyah;
}

Tags:

Misc Example