pickadate.js
  • Documentation
  • Discussions
  • GitHub
  • v3 Docs

›API

Getting Started

  • Introduction
  • Installation
  • Usage

Bindings

  • Plain JavaScript
  • React DOM
  • React Native
  • jQuery

Guides

  • Using Translations
  • Creating Custom Actors
  • Upgrading from v3

API

  • The State Object
  • The Picker Object
  • The Store Object
  • The Translation Object

The State Object

Below is a list of all the valid state properties.

selected

Type
Date | null

The date selected by the user.

Default value

const selected = null

highlighted

Type
Date

The date highlighted while navigating around the picker.

Default value

const highlighted = initialState.view

view

Type
Date

The date used to represent the currently visible month.

Default value

const view = new Date()

firstDayOfWeek

Type
0 | 1 | 2 | 3 | 4 | 5 | 6

The index of the first day of the week.

0 → Sunday

6 → Saturday

Default value

const firstDayOfWeek = 0

maximum

Type
Date | null

The maximum date that can be selected.

Default value

const maximum = null

minimum

Type
Date | null

The minimum date that can be selected.

Default value

const minimum = null

disabled

Type
Array<number | Date | [Date, Date]>

The list of disabled dates.

For numbers: that particular day of the week is disabled.

For dates: that specific date is disabled.

For tuples of two dates: they're used as a range of "from" and "to" dates to disable.

Default value

const disabled = []

template

Type
string

The template used to format the selected date value.

The formatting hooks listed below can be used in the template.

Default value

const template = 'D MMMM, YYYY @ h:mm a'

Formatting hooks

HookDescriptionResult
DDate of the month1 - 31
DDDate of the month with a leading zero01 - 31
DDDDay of the week in short formSun - Sat
DDDDDay of the week in full formSunday - Saturday
MMonth of the year1 - 12
MMMonth of the year with a leading zero01 - 12
MMMMonth name in short formJan - Dec
MMMMMonth name in full formJanuary - December
YYYYThe year2000 - 2999
HHours in 24-hour format0 - 23
HHHours in 24-hour format with a leading zero00 - 23
hHours in 12-hour format1 - 12
hhHours in 12-hour format with a leading zero01 - 12
mMinutes in hour0 - 59
mmMinutes in hour with a leading zero00 - 59
aDay time period (meridiem)a.m. / p.m.
ADay time period in uppercase (meridiem)AM / PM
sSeconds in minute0 - 59
ssSeconds in minute with a leading zero00 - 59
xThe unix time stamp587534400000

Escaping formatting hooks

In order to type out characters of formatting hooks literally, they can be escaped by surrounding them with square brackets ([]).

For example:

'Unescaped MMMM' // Output: 'Unescaped January'

In contrast to:

'Escaped [MMMM]' // Output: 'Escaped MMMM'

templateHookWords

Type
{
  [string]: string[],
}

A mapping of hooks to words for the parser to use.

Default value

const templateHookWords = {
  MMM  : ['Jan', 'Feb', ..., 'Dec'],
  MMMM : ['January', 'February', ..., 'December'],
  DDD  : ['Sun', 'Mon', ..., 'Sat'],
  DDDD : ['Sunday', 'Monday', ..., 'Saturday'],
}
← Upgrading from v3The Picker Object →
  • selected
  • highlighted
  • view
  • firstDayOfWeek
  • maximum
  • minimum
  • disabled
  • template
    • Formatting hooks
    • Escaping formatting hooks
  • templateHookWords
pickadate.js
Documentation
Getting StartedJavaScriptReact DOMReact NativejQuery
Community
Stack OverflowSpectrum
More
GitHubStar
Copyright © 2012-2019 Amsul and the pickadate.js documentation authors.