-
Notifications
You must be signed in to change notification settings - Fork 0
basic usage
github-actions[bot] edited this page May 30, 2026
·
2 revisions
import moment from 'moment';
import installHijri from 'moment-hijri-plus';
installHijri(moment);const today = moment();
const h = today.toHijri();
// Returns null if date is outside the UAQ range; guard before use.
if (h !== null) {
console.log(`${h.hd} / ${h.hm} / ${h.hy}`);
}// 23 March 2023 = 1 Ramadan 1444 AH
const m = moment('2023-03-23');
console.log(m.hijriYear()); // 1444
console.log(m.hijriMonth()); // 9 (Ramadan is the 9th month)
console.log(m.hijriDay()); // 1const gregorian = moment.fromHijri(1444, 9, 1);
console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23'const m = moment('2023-03-23');
m.formatHijri('iD iMMMM iYYYY'); // '1 Ramadan 1444'
m.formatHijri('iDD/iMM/iYYYY'); // '01/09/1444'
m.formatHijri('YYYY-MM-DD'); // no Hijri tokens; passes through to moment.format
m.formatHijri('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)'const m = moment('2023-03-23');
const uaqYear = m.hijriYear(); // UAQ (default)
const fcnaYear = m.hijriYear({ calendar: 'fcna' }); // FCNA
console.log(uaqYear, fcnaYear);
// Near month boundaries, UAQ and FCNA may differ by one day.const moment = require('moment');
const installHijri = require('moment-hijri-plus').default;
installHijri(moment);
const m = moment('2023-03-23');
console.log(m.hijriYear()); // 1444moment-hijri-plus · MIT License · npm · Issues
Guides
Examples
Reference
- API Reference
- installHijri
- toHijri
- fromHijri
- formatHijri
- hijriYear / hijriMonth / hijriDay
- isValidHijri
- Architecture
- Benchmarks
Community