---
title: "Javascript Calendar Gregorian, Jalali & Hijri Example | Mobiscroll"
component: "Calendar"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/calendar/gregorian-jalali-hijri"
---

# Gregorian, Jalali & Hijri - JavaScript Calendar demo

Use a Javascript calendar date picker with Gregorian, Jalali (Persian), and Hijri (Arabic) calendar system support for regional date selection. Plain JavaScript API.

- [Live demo](https://demo.mobiscroll.com/javascript/calendar/gregorian-jalali-hijri)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-javascript/tree/main/src/demos/datepicker/calendar/gregorian-jalali-hijri)
- This demo in other frameworks: [jQuery](https://demo.mobiscroll.com/jquery/calendar/gregorian-jalali-hijri.md), [Angular](https://demo.mobiscroll.com/angular/calendar/gregorian-jalali-hijri.md), [React](https://demo.mobiscroll.com/react/calendar/gregorian-jalali-hijri.md), [Vue](https://demo.mobiscroll.com/vue/calendar/gregorian-jalali-hijri.md)

## Description

The date picker supports multiple calendar systems. You can control it with the [`calendarSystem`](https://mobiscroll.com/docs/javascript/datepicker/api#localization-calendarSystem) setting, and it supports the following options:

- **Gregorian** - it is included by default
- **Jalali** - it is the default system of the Persian calendar and is included within the Farsi language pack
- **Hijri** - it is included in the Arabic language pack

**Interested in localization?** [Explore this example →](https://demo.mobiscroll.com/javascript/calendar/localization)

## What this demo shows

- Shows date picker examples for selecting a single date.
- **Calendar system picker** The left side of the calendar shows a "Pick a calendar system" label with three options, where Gregorian is selected by default and choosing another option (Jalali or Hijri) updates the calendar system.
- **Header navigation** The month and year label in the top left opens a month and year picker. The blue previous and next arrow buttons on the right navigate between months.
- **Month view** A fixed weekday header displays abbreviated day names from Sunday through Saturday, with the dates arranged in a grid below it.
- **Month navigation** The month can be changed by clicking and dragging the calendar left or right.
- **Day cell states** Hovering a day highlights the day number with a gray background. Selecting a day highlights the day number with a blue background. The current date is highlighted by default and remains blue when the user selects another date.
- **Adjacent months** Dates from the previous and next months appear with a muted style. Selecting one navigates the calendar to the corresponding month.

## Best for

- **Regional user experiences** Products that need to present dates in the calendar system users already rely on, such as Gregorian for international audiences, Jalali for Persian-speaking users, or Hijri for Arabic-speaking users.

## Tutorial

### Pick a calendar system

- (x) Gregorian
- ( ) Jalali
- ( ) Hijri

```js
mobiscroll.datepicker('#picker', {
    locale: mobiscroll.localeEn
});
```

With "Jalali":

```js
mobiscroll.datepicker('#picker', {
    calendarSystem: mobiscroll.jalaliCalendar,
    locale: mobiscroll.localeFa
});
```

With "Hijri":

```js
mobiscroll.datepicker('#picker', {
    calendarSystem: mobiscroll.hijriCalendar,
    locale: mobiscroll.localeAr
});
```

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-themeVariant) - option
- [`controls`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-controls) - option
- [`display`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-display) - option
- [`locale`](https://mobiscroll.com/docs/javascript/datepicker/api#localization-locale) - option
- [`calendarSystem`](https://mobiscroll.com/docs/javascript/datepicker/api#localization-calendarSystem) - option

## Code

### JS

```js
mobiscroll.setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

mobiscroll.datepicker('#demo-gregorian', {
  controls: ['calendar'],
  display: 'inline',
  locale: mobiscroll.locale.en,
});

mobiscroll.datepicker('#demo-jalali', {
  controls: ['calendar'],
  display: 'inline',
  calendarSystem: mobiscroll.jalaliCalendar,
  locale: mobiscroll.locale.fa,
});

mobiscroll.datepicker('#demo-hijri', {
  controls: ['calendar'],
  display: 'inline',
  calendarSystem: mobiscroll.hijriCalendar,
  locale: mobiscroll.locale.ar,
});
```

### HTML

```html
<div id="demo-gregorian"></div>
<div id="demo-jalali"></div>
<div id="demo-hijri"></div>
```

## Implementation notes

- Use `controls: ['calendar']` and `display: 'inline'`. `calendarSystem` and `locale` can be updated together at runtime via `setOptions({ calendarSystem, locale })` to switch which calendar system is active on a single picker instance.
- The picker initializes with no `calendarSystem`/`locale` set, defaulting to Gregorian/English. Selecting `Jalali` sets `calendarSystem: jalaliCalendar` with `locale: localeFa`; selecting `Hijri` sets `calendarSystem: hijriCalendar` with `locale: localeAr`; selecting `Gregorian` again explicitly sets `calendarSystem: gregorianCalendar` with `locale: localeEn` - `gregorianCalendar` and `localeEn` are real exports/namespace members used to switch back, not options the API lacks.
- React/Angular/Vue import `gregorianCalendar`, `jalaliCalendar`, `hijriCalendar`, `localeEn`, `localeFa`, `localeAr` as named exports from `@mobiscroll/react`/`@mobiscroll/angular`/`@mobiscroll/vue`; JS/jQuery reference them off the `mobiscroll` namespace (`mobiscroll.gregorianCalendar`, `mobiscroll.jalaliCalendar`, `mobiscroll.hijriCalendar`, `mobiscroll.locale.en`, `mobiscroll.locale.fa`, `mobiscroll.locale.ar`).
- The `locale` supplies month/day names and RTL layout direction alongside the calendar system's date rules for the non-Gregorian systems.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-javascript.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config javascript
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config javascript --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/javascript/getting-started/installation

## Related demos

- Previous: [Event Hooks](https://demo.mobiscroll.com/javascript/calendar/event-hooks.md) - Explore Javascript date picker lifecycle hooks — see which events fire on change, set, and init, and use the live event log to understand callback timing.
- Next: [Localization](https://demo.mobiscroll.com/javascript/calendar/localization.md) - Localize a Javascript date picker across 37 languages — configure regional date/time formats, RTL layout, and button labels, with manual overrides.
