---
title: "Javascript Date & Time Calendar systems  Example | Mobiscroll"
component: "Date & Time"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/datetime/gregorian-jalali-hijri"
---

# Calendar systems - JavaScript Date & Time demo

Javascript Date & time supporting calendar systems: Gregorian, Hijri and Jalali along with different languages and cultures. Plain JS api for usage everywhere.

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

## What this demo shows

- Shows a wheel-style inline date picker with different calendar systems.
- **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.
- **Inline date picker** The example embeds the picker directly in the page without an input by using inline display mode.
- **Date selection** Separate scrollable wheels let users select the month, day, and year. The selected values appear in a central selection area, while neighboring values remain visually subdued.
- **Scrolling behavior** Users can scroll vertically through neighboring values to move between dates, including dates in other months or years.

## 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: ['date'],
  display: 'inline',
  locale: mobiscroll.locale.en,
});

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

mobiscroll.datepicker('#demo-hijri', {
  controls: ['date'],
  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: ['date']` and `display: 'inline'` on a single inline `Datepicker` (wheel-style, not the month-grid `calendar` control). `calendarSystem` and `locale` can be changed at runtime via `setOptions({ calendarSystem, locale })` on the same instance to switch between calendar systems.
- 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: [Lifecycle events](https://demo.mobiscroll.com/javascript/datetime/event-hooks.md) - Javascript Date and time for mobile and desktop with event hooks for custom integration and functionality. With source code.
- Next: [Localization](https://demo.mobiscroll.com/javascript/datetime/localization.md) - Javascript Date & time picker localization example supporting 37 languages, date, time formats with full RTL capability.
