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

# Time Range Picker - JavaScript Range demo

Select start and end times with the Javascript time range picker — inline scroller, time grid, or single/split input layouts for any form design. Plain JS api for usage everywhere.

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

## Description

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

- `time` - will render a time picker or dropdown for range selection
- `timegrid` - will render a time grid for 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))
- `datetime` - will render a compact date scroller or dropdown with time picker for date & time range selection ([explore date & time ranges](https://demo.mobiscroll.com/javascript/range/date-time-range))

## What this demo shows

- Four inline examples of time-only range selection, each using a different control configuration.
- **Inline time scroller** A compact scroller for picking start and end times directly on the page, without any date component.
- **Inline time grid** A time grid displayed at 30-minute increments, letting users select a start and end slot by tapping directly on the grid.
- **Single input with popover** One input field that opens a time range scroller as a popover on mobile and as a dropdown on desktop.
- **Separate start and end inputs** Dedicated input fields for start and end time, each opening its own popover/dropdown scroller. In all examples the selected start and end times are displayed above the picker component.

## Best for

- **Time-only scheduling** Use cases where only the time range matters and no date needs to be selected, such as setting working hours, defining shift windows, or configuring opening times.
- **Slot-based selection** The time grid variant is well-suited for appointment booking or resource scheduling where time is divided into fixed increments.
- **Flexible form layouts** The four examples cover the main form patterns (inline, single input, split inputs), making it straightforward to match the control to the surrounding form design.

## Tutorial

### Embeddable time range

Use the time range inline by setting the `display` option to `inline`. Learn about [the different ways to use the picker](https://demo.mobiscroll.com/javascript/range/usage-on-input-or-inline).

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

### Time range selection with a time grid

For a time grid rendering pass `'timegrid'` to the `controls` option.

```js
mobiscroll.datepicker('#picker', {
    controls: ['timegrid'],
    select: 'range',
    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 [the different ways to display the picker](https://demo.mobiscroll.com/javascript/range/mobile-desktop-display).

```js
mobiscroll.datepicker('#picker', {
    controls: ['time'],
    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: ['time'],
    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-time', {
  controls: ['time'],
  select: 'range',
  display: 'inline',
});

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

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

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

### HTML

```html
<div id="demo-time"></div>
<div id="demo-timegrid"></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'` together with `controls` to pick the time-range rendering: `['time']` renders a scroller/dropdown time picker, `['timegrid']` renders a tappable time grid (30-minute slots in this demo), `['date']`/`['calendar']` render date-only range pickers, and `['datetime']` renders a combined date & time range picker.
- Set `display: 'inline'` to embed the picker directly in the page instead of anchoring it to an input.
- For a single-input range, initialize the `Datepicker` on one input element (or bind `value`/`v-model`/`[(ngModel)]` in the component frameworks) - the same input shows both the selected start and end time.
- For two separate inputs, pass `startInput` and `endInput` pointing at the start/end fields: JS/jQuery take CSS selector strings (`startInput: '#start', endInput: '#end'`); React takes state/ref values (`startInput={start} endInput={end}`) set via input `ref` callbacks; Vue takes `ref()` values bound with `:startInput="startInput" :endInput="endInput"`; Angular takes template reference variables bound with `[startInput]="start" [endInput]="end"` where `start`/`end` are declared with `#start`/`#end` on the corresponding `mbsc-input` elements.
- `touchUi` controls whether the time picker renders as a touch-friendly scroller (`true`) or a compact dropdown (`false`); it can be set directly in the options/props or updated at runtime via `.setOptions({ touchUi })` (JS/jQuery) or by updating the bound prop.

## 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: [Date Range Picker](https://demo.mobiscroll.com/javascript/range/date-range.md) - Set up a Javascript date range picker as a calendar view or date scroller — inline or in a popup, with one or two inputs.
- Next: [Date Time Range Picker](https://demo.mobiscroll.com/javascript/range/date-time-range.md) - Pick start and end date-times with the Javascript range picker — choose calendar, time grid, or date-time scroller with single or split inputs.
