Skip to content

Function: formatHijriDate()

@taqwim/core


@taqwim/core / formatHijriDate

formatHijriDate(hijriDate, formatStr, locale): string

Defined in: packages/core/src/lib/formatHijriDate.ts:39

Formats a Hijri date based on the provided format string.

The Hijri date object containing the year, month, and day.

number

number

number

string

The format string specifying how the Hijri date should be formatted.

string = 'en'

The locale to use for formatting the date. Defaults to “en”.

string

The formatted Hijri date as a string.

formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iYYYY/iMM/iDD", "ar");
//=> "1443/03/10"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iD iMMM, iYYYY", "en");
//=> "10 Rabiʻ II, 1443"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iEEEE, iD iMMMM iYYYY", "ar");
//=> "الأحد, 10 جمادى الثاني 1443"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iE, iD iMMM iYYYY", "en");
//=> "7, 10 Rabiʻ II 1443"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iD iMMM, iYYYY", "fr");
//=> "10 Rabiʻ II, 1443"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iD iMMM, iYYYY", "ar");
//=> "10 ربيع الثاني, 1443"
formatHijriDate({ hy: 1443, hm: 3, hd: 10 }, "iD iMMM, iYYYY", "en");
//=> "10 Rabiʻ II, 1443"