A lightweight Day.js plugin for Hijri calendar conversion and formatting.
This plugin adds Hijri calendar (Based on Umm al-Qura calculations) support to Day.js, enabling developers to seamlessly convert and manipulate Hijri dates while leveraging Day.js's lightweight API.
NPM
npm install --save dayjs-hijri
YARN
yarn add dayjs-hijri
import dayjs from 'dayjs'
import dayjsHijri from 'dayjs-hijri'
dayjs.extend(dayjsHijri)
- Parse Gregory date
const date = dayjs('2025-01-07T16:00:00.000Z');
- Parse hijri date that only gives you a dayjs object that has only Gregory date
const date = dayjs('1446-10-17', { hijri: true });
If you want to all new instanses of dayjs use hijri
calendar, you can set default calendar
dayjs.calendar('hijri') // hijri Calendar
// OR
dayjs.calendar('gregory') // Gregorian Calendar
also you can create a hijri date without changing default calendar
const date = dayjs()
const hijriDate = date.calendar('hijri')
with combination of calendar
and locale
we have multi language for real
dayjs('2025-01-07').calendar('hijri').locale('en').format('DD MMMM YYYY') // '07 Rajab 1446'
dayjs('1446-07-07').calendar('gregory').locale('ar').format('DD MMMM YYYY') // '07 ینایر 2025'
Try the plugin live on CodeSandbox: Open Demo.
MIT © 2025 M25D