---
title: "Javascript Range Date & Time Range Picker Example | Mobiscroll"
component: "Range"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/range/date-time-range"
---

# Date & Time Range Picker - JavaScript Range demo

Pick start and end date-times with the Javascript range picker — choose from calendar, time grid, or date-time scroller, with single or split input layouts. Plain JavaScript API.

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

## Description

Set up the range picker for date & time pair selection. Regardless if you are interested in the start/end date or the actual range, you have several possibilities of rendering a date and time range picker. The `controls` option supports different values:

- `datetime` - will render a compact date scroller or dropdown with time picker for date & time range selection
- `calendar` - will render a calendar view for date range selection ([explore date ranges](https://demo.mobiscroll.com/javascript/range/date-range))
- `date` - will render a date scroller or dropdown for date range selection ([explore date ranges](https://demo.mobiscroll.com/javascript/range/date-range))
- `time` - will render a time picker for range selection ([explore time ranges](https://demo.mobiscroll.com/javascript/range/time-range))
- `timegrid` - will render a time grid for range selection ([explore time range selection](https://demo.mobiscroll.com/javascript/range/time-range))

## What this demo shows

- Five inline examples of date-and-time range selection, each using a different control configuration.
- **Calendar + time picker** A month calendar for date selection combined with a time picker, giving a familiar two-panel layout for picking start and end date-times.
- **Calendar + time grid** A month calendar paired with a time grid at 30-minute increments, suited for slot-based selection.
- **Date-time scroller** A compact inline scroller combining date and time in a single control for both the start and end values.
- **Single input with popover/dropdown** One input field that opens a date-time range scroller as a popover on mobile and as a dropdown on desktop.
- **Separate start and end inputs** Same responsive behavior as the single-input example, but with dedicated input fields for the start and end date-time. In all examples the selected start and end date-times are displayed above the picker component.

## Best for

- **Flexible form configurations** The five examples cover the most common form layouts: fully inline, single-input, and split start/end inputs, making it easy to pick the right pattern for a given form design.
- **Use-cases that need both date and time precision** Booking systems, scheduling tools, or any workflow where selecting just a date is not enough and the time component is required for both ends of the range.
- **Responsive UIs** The popover/dropdown examples demonstrate how the same control adapts between mobile and desktop without additional configuration.

## Tutorial

### Range with a calendar and time picker

One of the most common ways to represent date range selection is through a calendar with or without a time picker. Learn how to build [a date-only picker](https://demo.mobiscroll.com/javascript/range/date-range).

```js
mobiscroll.datepicker('#picker', {
    controls: ['calendar', 'time'],
    select: 'range',
    display: 'inline',
    touchUi: true
});
```

### Range with a calendar and time grid

Instead of selecting time from a list of values you can show a grid by passing `'timegrid'` to the `controls` option.

```js
mobiscroll.datepicker('#picker', {
    controls: ['calendar', 'timegrid'],
    select: 'range',
    display: 'inline',
    touchUi: true
});
```

### Range with a scroller/dropdown

Passing `datetime` to the `controls` option renders a compact date scroller and a time scroller or dropdown with [customizable start and end labels](https://demo.mobiscroll.com/javascript/range/customizing-labels-selection).

```js
{
    controls: ['datetime'],
    select: 'range',
    display: 'inline',
    touchUi: true
}
```

### Using the range with one input

Besides rendering it inline, you can link the range to an input that can be a Mobiscroll input or an existing field. Explore [more ways to use the picker](https://demo.mobiscroll.com/javascript/range/usage-on-input-or-inline).

```js
mobiscroll.datepicker('#picker', {
    controls: ['datetime'],
    select: 'range',
    touchUi: true
});
```

### Using the range with two inputs

When using two separate inputs for `start` and `end`, you will want to initialize the component on the first input and make sure to pass the references of the two inputs through the `startInput` and `endInput` options.

```html
<div id="range"></div>
<label>
    Start
    <input id="start" mbsc-input placeholder="Please select..." />
</label>
<label>
    End
    <input id="end" mbsc-input placeholder="Please select..." />
</label>
```

```js
mobiscroll.datepicker('#range', {
    controls: ['datetime'],
    select: 'range',
    startInput: '#start',
    endInput: '#end',
    touchUi: true
});
```

## 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
- [`select`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-select) - option
- [`display`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-display) - option
- [`startInput`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-startInput) - option
- [`endInput`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-endInput) - option

## Code

### JS

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

mobiscroll.datepicker('#demo-calendar', {
  controls: ['calendar', 'time'],
  select: 'range',
  display: 'inline',
});

mobiscroll.datepicker('#demo-calendar-timegrid', {
  controls: ['calendar', 'timegrid'],
  select: 'range',
  display: 'inline',
});

mobiscroll.datepicker('#demo-date', {
  controls: ['datetime'],
  select: 'range',
  display: 'inline',
});

mobiscroll.datepicker('#demo-one-input', {
  controls: ['datetime'],
  select: 'range',
});

mobiscroll.datepicker('#demo-start-end', {
  controls: ['datetime'],
  select: 'range',
  startInput: '#demo-start',
  endInput: '#demo-end',
});
```

### HTML

```html
<div id="demo-calendar"></div>
<div id="demo-calendar-timegrid"></div>

<div id="demo-date"></div>

<label>
    Range
    <input id="demo-one-input" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>

<div id="demo-start-end"></div>
<div class="mbsc-grid mbsc-no-padding">
    <div class="mbsc-row">
        <div class="mbsc-col-6">
            <label>
                Start
                <input id="demo-start" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
            </label>
        </div>
        <div class="mbsc-col-6">
            <label>
                End
                <input id="demo-end" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
            </label>
        </div>
    </div>
</div>
```

## Implementation notes

- Set `select: 'range'` on the `Datepicker` for every configuration below - it is what turns single-value selection into start/end range selection.
- Use `controls: ['calendar', 'time']` for a calendar paired with a scroller-style time picker, or `controls: ['calendar', 'timegrid']` to pair the calendar with a 30-minute time grid instead of scroller wheels.
- Use `controls: ['datetime']` alone for the compact combined date-and-time scroller/dropdown layout (both inline and input-anchored).
- Set `display: 'inline'` to render the picker directly on the page, or omit `display` (default `'anchored'`) to open it from an input.
- For a single input driving the whole range, initialize the picker directly on that input element/ref.
- For two separate start/end inputs, initialize the picker once and pass `startInput`/`endInput` pointing at the two input elements/refs - React/Vue/Angular pass element refs (`startInput={start}` / `:startInput="startInput"` / `[startInput]="start"`), JS/jQuery pass selector strings (`startInput: '#start'`, `endInput: '#end'`).

## 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: [Time Range Picker](https://demo.mobiscroll.com/javascript/range/time-range.md) - Select start and end times with the Javascript time range picker — choose inline scroller, time grid, or single/split input layouts.
- Next: [Range Picker Customization](https://demo.mobiscroll.com/javascript/range/week-month-view-scrolling-direction.md) - Show multiple months or weeks in the Javascript date range picker calendar — set scroll direction, display count, week numbers, and outer day visibility.
