---
title: "Javascript Date & Time Setting time select steps Example | Mobiscroll"
component: "Date & Time"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/datetime/time-value-steps"
---

# Setting time select steps - JavaScript Date & Time demo

Javascript Date and time demo with 5 and 15 minute steps. Control hour, minute and second steps. With source code. Plain JS api for usage everywhere.

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

## Description

Adjust the gaps between the time picker values as needed. Use these three options for setting the steps:

- `stepHour` - adjusts the gaps between the values for the time wheel
- `stepMinute` - adjusts the gaps between the values for the minute wheel
- `stepSecond` - adjusts the gaps between the values for the second wheel

## What this demo shows

- Four wheel-style date and time picker configurations for selecting a single date and time or a time value with different step intervals.
- **Date and time picker** The first example uses separate scrollable wheels for the date, hour, minute, and AM/PM. Minute values appear at 15-minute intervals. The current date is labeled `Today`, other dates use an abbreviated weekday, month, and date format.
- **Time picker with 5-minute steps** The second example uses separate scrollable wheels for the hour, minute, and AM/PM. Minute values appear at 5-minute intervals.
- **Time picker with 2-hour steps** The third example uses separate scrollable wheels for the hour, minute, and AM/PM. Hour values appear at 2-hour intervals.
- **Time picker with 30-second steps** The fourth example uses separate scrollable wheels for the hour, minute, and second. Second values appear at 30-second intervals.
- **Input behavior** Each picker opens at the bottom of the container over a darkened backdrop. Clicking outside the picker closes it.
- **Scrolling behavior** The selected values appear in a central selection area, while neighboring values are visually subdued. Users scroll vertically through each wheel to change the selection.
- **Footer actions** In the input-based examples, `Cancel` discards the changes and `Set` confirms the selected values.
- **Input value** After the user selects `Set`, the input displays the confirmed value in the format configured for that example.

## Best for

- **15-minute appointments** Booking interfaces for consultations, classes, or services that begin at quarter-hour intervals.
- **5-minute scheduling** Selecting precise start times for short appointments, transport departures, or other activities organized in 5-minute increments.
- **2-hour time blocks** Planning shifts, equipment reservations, or activities scheduled in larger blocks.
- **30-second precision** Selecting time values for short-duration processes, exercise intervals, or timed operational tasks that require half-minute increments.

## Tutorial

```js
mobiscroll.datepicker('#step15min-picker-picker', {
    controls: ['datetime'],
    stepMinute: 15,
    touchUi: true
});
```

```js
mobiscroll.datepicker('#step5min-picker-picker', {
    controls: ['time'],
    stepMinute: 5,
    touchUi: true
});
```

```js
mobiscroll.datepicker('#step2h-picker-picker', {
    controls: ['time'],
    stepHour: 2,
    touchUi: true
});
```

```js
mobiscroll.datepicker('#step30sec-picker-picker', {
    controls: ['time'],
    stepSecond: 30,
    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
- [`stepMinute`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-stepMinute) - option
- [`stepHour`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-stepHour) - option
- [`stepSecond`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-stepSecond) - option
- [`timeFormat`](https://mobiscroll.com/docs/javascript/datepicker/api#localization-timeFormat) - option

## Code

### JS

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

mobiscroll.datepicker('#demo-15m', {
  controls: ['datetime'],
  stepMinute: 15,
});

mobiscroll.datepicker('#demo-5m', {
  controls: ['time'],
  stepMinute: 5,
});

mobiscroll.datepicker('#demo-2h', {
  controls: ['time'],
  stepHour: 2,
});

mobiscroll.datepicker('#demo-30s', {
  controls: ['time'],
  stepSecond: 30,
  timeFormat: 'HH:mm:ss',
});
```

### HTML

```html
<label>
    Date & Time (every 15 min)
    <input id="demo-15m" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>

<label>
    Time (every 5 min)
    <input id="demo-5m" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>

<label>
    Time (every 2 hours)
    <input id="demo-2h" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>

<label>
    Time (every 30 seconds)
    <input id="demo-30s" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>
```

## Implementation notes

- Four separate input-bound picker instances, each with a fixed step configuration - there is no live switcher in this demo; each variant is a distinct static instance.
- **Date and time, 15-minute steps**: `controls: ['datetime'], stepMinute: 15` - combines the date wheel with hour/minute/AM-PM wheels, restricting the minute wheel to quarter-hour values.
- **Time, 5-minute steps**: `controls: ['time'], stepMinute: 5` - restricts the minute wheel to 5-minute increments.
- **Time, 2-hour steps**: `controls: ['time'], stepHour: 2` - restricts the hour wheel to 2-hour increments.
- **Time, 30-second steps**: `controls: ['time'], stepSecond: 30, timeFormat: 'HH:mm:ss'` - adds a second wheel (via the `HH:mm:ss` format) restricted to 30-second increments.
- Each instance is bound to a Mobiscroll-generated input (`mbsc-input`, `data-input-style="outline"`, `data-label-style="stacked"`) rather than rendered inline.
- `stepHour`, `stepMinute`, and `stepSecond` are independent options - a given instance sets only the step(s) relevant to the wheels it renders; unset step options default to 1.

## 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 & time selection](https://demo.mobiscroll.com/javascript/datetime/date-time-picker.md) - Javascript Datetime scroller demo with date, hour and minute wheels. Featuring iPhone style rendering and format. With source code.
