Skip to content

Time picker, 12 or 24 hours ​

Hours and minutes, with seconds if you want them. The value is `14:30`, always on 24 hours, whatever the reader sees.

The code ​

import { createDatePicker } from '@nervure/datetime';

createDatePicker('#field', {
  mode: 'time',
  minuteStep: 15,
  onChange: (selection) => console.log(selection.value, selection.start, selection.end),
});

The value is '14:30'. Read the guide for every option, and see every example.

What it does ​

  • AM and PM follow the language (en-US), or hour12.
  • The arrow keys change a field by its step.

Why this one ​

  • No dependency, about 18 kB gzipped for every mode, zone and language.
  • Values are ISO 8601 text. Each selection also gives two instants, start and end, in the time zone.
  • 28 languages and right to left. Keyboard and screen readers.
  • Your CSS and your colours, through CSS variables. Light and dark.
  • The same picker in plain JavaScript, as a web component, in React and in Vue.