Skip to content
العربية
Saudi and bilingual kit

formatDate

Gregorian and Hijri (Umm al-Qura) dates with Western digits. Riyadh time by default, so the server and the browser agree.

import { formatDate, hijriParts } from "@percentsa/ui";

Examples

18 February 2026

1 Ramadan 1447 AH

01/09/1447 AH

Code
export function DatesExample() {
  const lang = useLang();
  const day = new Date("2026-02-18T12:00:00Z");
  return (
    <Stack gap={2}>
      <Text>{formatDate(day, { lang })}</Text>
      <Text>{formatDate(day, { lang, calendar: "hijri" })}</Text>
      <Text tone="muted">{formatDate(day, { lang, calendar: "hijri", style: "short" })}</Text>
    </Stack>
  );
}

// A fixed "now" (Sunday 27 September 2026, 3:45 PM in Riyadh), so the server and the browser show the same text.
const NOW = new Date("2026-09-27T12:45:00Z");