-
Notifications
You must be signed in to change notification settings - Fork 0
quickstart
github-actions[bot] edited this page May 29, 2026
·
1 revision
This guide covers the most common use cases in moment-hijri-plus. All examples use the default Umm al-Qura (UAQ) calendar.
pnpm add moment moment-hijri-plus hijri-coremoment and hijri-core are required peer dependencies. Install both alongside this package.
import moment from 'moment';
import hijri from 'moment-hijri-plus';
moment.extend(hijri);After extending, all moment() instances gain Hijri methods.
import moment from 'moment';
import hijri from 'moment-hijri-plus';
moment.extend(hijri);
const m = moment('2023-03-23'); // 1 Ramadan 1444
console.log(m.iYear()); // 1444
console.log(m.iMonth()); // 9
console.log(m.iDate()); // 1m.format('iYYYY/iMM/iDD'); // '1444/09/01'
m.format('iD iMMMM iYYYY'); // '1 Ramadan 1444'Hijri format tokens are prefixed with i to avoid conflicts with Moment.js Gregorian tokens.
import moment from 'moment';
import hijri from 'moment-hijri-plus';
moment.extend(hijri);
const m = moment.fromHijri(1444, 9, 1);
console.log(m.format('YYYY-MM-DD')); // '2023-03-23'const m = moment('2023-03-23');
console.log(m.iYear({ calendar: 'fcna' })); // 1444Moment.js is in maintenance mode. The Moment team recommends Luxon, Day.js, or date-fns for new projects. If you are starting fresh, consider dayjs-hijri-plus as a compatible alternative.
const moment = require('moment');
const hijri = require('moment-hijri-plus');
moment.extend(hijri);
const m = moment('2023-03-23');
console.log(m.iYear(), m.iMonth(), m.iDate()); // 1444 9 1- API Reference for the full method list
- Architecture for how the plugin integrates with Moment.js
moment-hijri-plus · MIT License · npm · Issues
Guides
Examples
Reference
- API Reference
- installHijri
- toHijri
- fromHijri
- formatHijri
- hijriYear / hijriMonth / hijriDay
- isValidHijri
- Architecture
- Benchmarks
Community