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 Picker Object

The picker object provides methods to manage the UI and actions to update the state.

It can be used to customize and extend the functionality of any renderer.

Properties

store

The store object contains the state of the picker.

For a full reference, read the API of the Store Object.

Methods

getValue

ArgumentsReturns
template: string (optional)string

Gets the current selected value as a formatted string.

const value = picker.getValue()
console.log(value) // '1 January, 2019 @ 12:00 a.m.'

With the optional template argument, the string can be formatted using the formatting hooks.

const value = picker.getValue('YYYY-MM-DD')
console.log(value) // '2019-01-01'

subscribeToSelection

ArgumentsReturns
callback: Functionunsubscribe: Function

Subscribes to updates to the selected value.

The function returned can be called to unsubscribe to the updates.

const callback = ({ value, date }) => {
  console.log(value) // '1 January, 2019 @ 12:00 a.m.'
  console.log(date.getTime()) // 1546318800000
}
const unsubscribe = picker.subscribeToSelection(callback)

Actions

setSelected

ArgumentsReturns
{
  value: Date | string | number,
  isUpdatingView?: boolean,
}
nothing

An action that sets the selected state of the store.

Note: isUpdatingView defaults to true. To prevent updating the view, set it to false.

picker.setSelected({
  value: new Date(2020, 0, 1),
})

setHighlighted

ArgumentsReturns
{
  keyCode: number,
}
nothing

An action that sets the highlighted state of the store using a keyboard event's key code.

For instance, the "up" key's key code highlights the date 7 days before the currently highlighted date.

picker.setHighlighted({
  keyCode: 39,
})

setMaximum

ArgumentsReturns
{
  value: Date,
}
nothing

An action that sets the maximum state of the store.

picker.setMaximum({
  value: new Date(2021, 0, 1),
})

setMinimum

ArgumentsReturns
{
  value: Date,
}
nothing

An action that sets the minimum state of the store.

picker.setMinimum({
  value: new Date(2019, 1, 1),
})

setTime

ArgumentsReturns
{
  hours?: number,
  minutes?: number,
}
nothing

An action that sets the time of the selected state of the store.

picker.setTime({
  hours: 9,
})

setFirstDayOfWeek

ArgumentsReturns
{
  value: number,
}
nothing

An action that sets the firstDayOfWeek state of the store.

picker.setFirstDayOfWeek({
  value: 5,
})

clear

ArgumentsReturns
nonenothing

An action that clears the selected state of the store.

picker.clear()

viewNext

ArgumentsReturns
nonenothing

An action that updates the view and highlight state of the store to show the next month.

picker.viewNext()

viewPrevious

ArgumentsReturns
nonenothing

An action that updates the view and highlight state of the store to show the previous month.

picker.viewPrevious()

viewToday

ArgumentsReturns
nonenothing

An action that updates the view and highlight state of the store to show the month of "today".

picker.viewToday()

cycleHourUp

ArgumentsReturns
nonenothing

An action that updates the selected state of the store to cycle up through the hours of 1 - 12.

picker.cycleHourUp()

cycleHourDown

ArgumentsReturns
nonenothing

An action that updates the selected state of the store to cycle down through the hours of 1 - 12.

picker.cycleHourDown()

cycleMinuteUp

ArgumentsReturns
nonenothing

An action that updates the selected state of the store to cycle up through the minutes of 0 - 59.

picker.cycleMinuteUp()

cycleMinuteDown

ArgumentsReturns
nonenothing

An action that updates the selected state of the store to cycle down through the minutes of 0 - 59.

picker.cycleMinuteDown()

cycleMeridiem

ArgumentsReturns
nonenothing

An action that updates the selected state of the store to cycle the day time period (meridiem) between AM and PM.

picker.cycleMeridiem()
← The State ObjectThe Store Object →
  • Properties
    • store
  • Methods
    • getValue
    • subscribeToSelection
  • Actions
    • setSelected
    • setHighlighted
    • setMaximum
    • setMinimum
    • setTime
    • setFirstDayOfWeek
    • clear
    • viewNext
    • viewPrevious
    • viewToday
    • cycleHourUp
    • cycleHourDown
    • cycleMinuteUp
    • cycleMinuteDown
    • cycleMeridiem
pickadate.js
Documentation
Getting StartedJavaScriptReact DOMReact NativejQuery
Community
Stack OverflowSpectrum
More
GitHubStar
Copyright © 2012-2019 Amsul and the pickadate.js documentation authors.