Examples

    without any config.

    DateTime

    Human-friendly Dates

    altInput hides your original input and creates a new one.

    Upon date selection, the original input will contain a Y-m-d… string, while the altInput will display the date in a more legible, customizable format.

    Enabling this option is highly recommended.

    1. {
    2. altInput: true,
    3. altFormat: "F j, Y",
    4. dateFormat: "Y-m-d",
    5. }

    After selecting a date, inspect this input to see how it works.

    Supplying Dates for flatpickr

    flatpickr has numerous options that accept date values in a variety of formats. Those are:

    • defaultDate
    • minDate
    • maxDate
    • enable/disableThe values accepted by these options all follow the same guidelines.

    You may specify those dates in a variety of formats:

    • are always accepted
      • new Date(2015, 0, 10)
    • Timestamps are always accepted
      • e.g. 1488136398547
    • ISO Date Strings are always accepted
      • e.g. "2017-02-26T19:40:03.243Z"
      • dateFormat defaults to YYYY-MM-DD HH:MM
      • This means that "2016" "2016-10", "2016-10-20", "2016-10-20 15", "2016-10-20 15:30" are all valid date strings
    • The shortcut "today"

    Preloading a Date

    The selected date will get parsed from the input’s value or the defaultDate option.

    See supplying dates for valid date examples.

    minDate option specifies the minimum/earliest date (inclusively) allowed for selection.

    maxDate option specifies the maximum/latest date (inclusively) allowed for selection.

    1. {
    2. minDate: "2020-01"
    3. }
    1. {
    2. dateFormat: "d.m.Y",
    3. maxDate: "15.12.2017"
    4. }
    1. {
    2. minDate: "today"
    3. }
    1. {
    2. minDate: "today",
    3. maxDate: new Date().fp_incr(14) // 14 days from now
    4. }

    Disabling dates

    If you’d like to make certain dates unavailable for selection, there are multiple methods of doing so.

    • Disabling specific date
    • Disabling a date range
    • Disabling dates using a functionAll of those are possible with the disable option.

    1. {
    2. disable: ["2025-01-30", "2025-02-21", "2025-03-08", new Date(2025, 4, 9) ],
    3. dateFormat: "Y-m-d",

    Disabling range(s) of dates:

    1. {
    2. dateFormat: "Y-m-d",
    3. disable: [
    4. {
    5. from: "2025-04-01",
    6. to: "2025-05-01"
    7. },
    8. {
    9. from: "2025-09-01",
    10. to: "2025-12-01"
    11. }
    12. ]
    13. }

    Disabling dates by a function:

    The function takes in a Date object, and should return a boolean value.If the function returns true, the date will be disabled.

    This flexibility allows us to use any arbitrary logic to disable dates.The example below disables Saturdays and Sundays.

    1. {
    2. "disable": [
    3. function(date) {
    4. // return true to disable
    5. }
    6. ],
    7. "locale": {
    8. "firstDayOfWeek": 1 // start week on Monday
    9. }
    10. }

    Disabling all dates except select few

    Enabling specific dates


    1. {
    2. enable: [
    3. {
    4. from: "2025-04-01",
    5. to: "2025-05-01"
    6. },
    7. {
    8. from: "2025-09-01",
    9. to: "2025-12-01"
    10. }
    11. ]
    12. }

    Enabling dates by a function:

    1. {
    2. enable: [
    3. function(date) {
    4. // return true to enable
    5. return (date.getMonth() % 2 === 0 && date.getDate() < 15);
    6. }
    7. ]
    8. }

    Selecting multiple dates

    It is possible to select multiple dates.

    1. {
    2. mode: "multiple",
    3. dateFormat: "Y-m-d"
    4. }

    Preloading multiple dates

    1. {
    2. mode: "multiple",
    3. dateFormat: "Y-m-d",
    4. defaultDate: ["2016-10-20", "2016-11-04"]
    5. }

    Customizing the Conjunction

    1. {
    2. mode: "multiple",
    3. dateFormat: "Y-m-d",
    4. conjunction: " :: "
    5. }

    Range Calendar

    Select a range of dates using the range calendar.

    1. {
    2. mode: "range"
    3. }

    Note that disabled dates (by either minDate, maxDate, enable or disable) will not be allowed in selections.

    1. {
    2. mode: "range",
    3. dateFormat: "Y-m-d",
    4. disable: [
    5. function(date) {
    6. // disable every multiple of 8
    7. return !(date.getDate() % 8);
    8. }
    9. ]
    1. {
    2. mode: "range",
    3. dateFormat: "Y-m-d",
    4. defaultDate: ["2016-10-10", "2016-10-20"]
    5. }

    24-hour Time Picker

    1. {
    2. enableTime: true,
    3. noCalendar: true,
    4. dateFormat: "H:i",
    5. time_24hr: true
    6. }

    Time Picker w/ Limits

    1. {
    2. enableTime: true,
    3. noCalendar: true,
    4. dateFormat: "H:i",
    5. minDate: "16:00",
    6. maxDate: "22:30",
    7. }

    Preloading Time

    1. {
    2. enableTime: true,
    3. noCalendar: true,
    4. dateFormat: "H:i",
    5. defaultDate: "13:45"
    6. }

    DateTimePicker with Limited Time Range

    1. {
    2. enableTime: true,
    3. minTime: "09:00"
    4. }
    1. {
    2. enableTime: true,
    3. minTime: "16:00",
    4. maxTime: "22:00"
    5. }

    Inline Calendar

    Display the calendar in an always-open state with the inline option.

    1. {
    2. inline: true
    3. }

    Display Week Numbers

    Enable the weekNumbers option to display the week number in a column left to the calendar.

    1. {
    2. weekNumbers: true,
    3. /*
    4. optionally, you may override the function that
    5. extracts the week numbers from a Date by
    6. supplying a getWeek function. It takes in a date
    7. as a parameter and should return a corresponding string
    8. that you want to appear left of every week.
    9. */
    10. getWeek: function(dateObj) {
    11. // ...
    12. }
    13. }

    flatpickr + external elements

    flatpickr can parse an input group of textboxes and buttons, common in Bootstrap and other frameworks.

    This permits additional markup, as well as custom elements to trigger the state of the calendar.

    1. <div class="flatpickr">
    2. <input type="text" placeholder="Select Date.." data-input> <!-- input is mandatory -->
    3. <a class="input-button" title="toggle" data-toggle>
    4. <i class="icon-calendar"></i>
    5. </a>
    6. <a class="input-button" title="clear" data-clear>
    7. <i class="icon-close"></i>
    8. </div>