Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS
Pull request Compare This branch is 183 commits behind dbushell:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A refreshing JavaScript Datepicker

  • Lightweight (less than 5kb minified and gzipped)
  • No dependencies (but plays well with Moment.js
  • Modular CSS classes for easy styling

Try Pikaday Demo →

Pikaday Screenshot

Production ready? Since version 1.0.0 Pikaday is stable and used in production. If you do however find bugs or have feature requests please submit them to the GitHub issue tracker.
Also see the changelog


Pikaday can be bound to an input field:

<input type="text" id="datepicker">

Add the JavaScript to the end of your document:

<script src="pikaday.js"></script>
    var picker = new Pikaday({ field: document.getElementById('datepicker') });

If you're using jQuery make sure to pass only the first element:

var picker = new Pikaday({ field: $('#datepicker')[0] });

If the Pikaday instance is not bound to a field you can append the element anywhere:

var field = document.getElementById('datepicker');
var picker = new Pikaday({
    onSelect: function(date) {
        field.value = picker.toString();
field.parentNode.insertBefore(picker.el, field.nextSibling);

For advanced formatting load Moment.js prior to Pikaday:
See the moment.js example for a full version.

<input type="text" id="datepicker" value="9 Oct 2012">

<script src="moment.js"></script>
<script src="pikaday.js"></script>
    var picker = new Pikaday({
        field: document.getElementById('datepicker'),
        format: 'D MMM YYYY',
        onSelect: function() {
            console.log(this.getMoment().format('Do MMMM YYYY'));


As the examples demonstrate above Pikaday has many useful options:

  • field bind the datepicker to a form field
  • trigger use a different element to trigger opening the datepicker, see trigger example (default to field)
  • bound automatically show/hide the datepicker on field focus (default true if field is set)
  • format the default output format for .toString() and field value (requires Moment.js for advanced formatting)
  • defaultDate the initial date to view when first opened
  • setDefaultDate make the defaultDate the initial selected value
  • firstDay first day of the week (0: Sunday, 1: Monday, etc)
  • minDate the minimum/earliest date that can be selected (this should be a native Date object - e.g. new Date() or moment().toDate())
  • maxDate the maximum/latest date that can be selected (this should be a native Date object - e.g. new Date() or moment().toDate())
  • yearRange number of years either side (e.g. 10) or array of upper/lower range (e.g. [1900,2012])
  • isRTL reverse the calendar for right-to-left languages
  • i18n language defaults for month and weekday names (see internationalization below)
  • onSelect callback function for when a date is selected
  • onOpen callback function for when the picker becomes visible
  • onClose callback function for when the picker is hidden
  • onDraw callback function for when the picker draws a new month

jQuery Plugin

The normal version of Pikaday does not require jQuery, however there is a jQuery plugin if that floats your boat (see plugins/pikaday.jquery.js in the repository). This version requires jQuery, naturally, and can be used like other plugins:
See the jQuery example for a full version.

<script src="//"></script>
<script src="pikaday.js"></script>
<script src="plugins/pikaday.jquery.js"></script>

// activate datepickers for all elements with a class of `datepicker`
$('.datepicker').pikaday({ firstDay: 1 });

// chain a few methods for the first datepicker, jQuery style!
$('.datepicker').eq(0).pikaday('show').pikaday('gotoYear', 2042);


AMD support

If you use a modular script loader than Pikaday is not bound to the global object and will fit nicely in your build process. You can require Pikaday just like any other module.
See the AMD example for a full version.

require(['pikaday'], function(Pikaday) {
    var picker = new Pikaday({ field: document.getElementById('datepicker') });

The same applies for the jQuery plugin mentioned above.
See the jQuery AMD example for a full version.

require(['jquery', 'pikaday.jquery'], function($) {

Ruby on Rails

If you're using Ruby on Rails, make sure to check out the Pikaday gem.


You can control the date picker after creation:

var picker = new Pikaday({ field: document.getElementById('datepicker') });

Get and set date


Returns the selected date in a string format. If Moment.js exists (recommended) then Pikaday can return any format that Moment understands, otherwise you're stuck with JavaScript's default.


Returns a basic JavaScript Date object of the selected day, or null if no selection.


Set the current selection. This will be restricted within the bounds of minDate and maxDate options if they're specified.


Returns a Moment.js object for the selected date (Moment must be loaded before Pikaday).

picker.setMoment(moment('14th Feburary 2013', 'DDo MMMM YYYY'))

Set the current selection with a Moment.js object (passed on to setDate).

Change current view

picker.gotoDate(new Date(2012, 1))

Change the current view to see a specific date. This example will jump to February 2012 (month is a zero-based index).


Shortcut for picker.gotoDate(new Date())


Change the current view by month (0: January, 1: Februrary, etc).

picker.nextMonth() picker.prevMonth()

Go to the next or previous month (this will change year if necessary).


Change the year being viewed.


Update the minimum/earliest date that can be selected.


Update the maximum/latest date that can be selected.

Show and hide datepicker


Returns true or false.

Make the picker visible.


Recalculate and change the position of the picker.


Hide the picker making it invisible.


Hide the picker and remove all event listeners — no going back!


The default i18n configuration format looks like this:

i18n: {
    previousMonth : 'Previous Month',
    nextMonth     : 'Next Month',
    months        : ['January','February','March','April','May','June','July','August','September','October','November','December'],
    weekdays      : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
    weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']

You must provide 12 months and 7 weekdays (with abbreviations). Always specify weekdays in this order with Sunday first. You can change the firstDay option to reorder if necessary (0: Sunday, 1: Monday, etc). You can also set isRTL to true for languages that are read right-to-left.



Pikaday is a pure datepicker. It will not support picking a time of day. However, there have been efforts to add time support to Pikaday.
See #1 and #18. These reside in their own fork.

You can use the work @stas did at stas/Pikaday
or the work @owenmead did more recently at owenmead/Pikaday which is based on version 1.1.0.

Browser Compatibility

  • IE 7+
  • Chrome 8+
  • Firefox 3.5+
  • Safari 3+
  • Opera 10.6+


Thanks to @shoogledesigns for the name.

Copyright © 2013 David Bushell | BSD & MIT license

Something went wrong with that request. Please try again.