JavaScript Date Range, Date and Time Picker Component

Overview

Date Range Picker

Improvely.com

This date range picker component creates a dropdown menu from which a user can select a range of dates. I created it while building the UI for Improvely, which needed a way to select date ranges for reports.

Features include limiting the selectable date range, localizable strings and date formats, a single date picker mode, a time picker, and predefined date ranges.

Documentation and Live Usage Examples

See It In a Live Application

License

The MIT License (MIT)

Copyright (c) 2012-2020 Dan Grossman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Allow start/end dates in a range to be null so there can be an 'All Time' range option

    Allow start/end dates in a range to be null so there can be an 'All Time' range option

    As originally described in #284,

    Use case: I'd like to have "All Time" be a range, but want to avoid hardcoding some date like 1/1/1900.

    ranges: {
        'Today': [moment(), moment()],
        'This Week': [moment().startOf('week'), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
        'All Time': []
    }
    

    The callback just returns null for start/end dates if this is chosen.

    opened by philfreo 15
  • Feature: Added functionality to select time along with date

    Feature: Added functionality to select time along with date

    I've updated example.html to demonstrate the new functionality.

    showTime : true enables the time picker select lists minuteIncrement sets the minute dropdown increment (must be a number that 60 is divisible by) minHour and maxHour limits the hour dropdown to a range (will override 12hr clock if set)

    Adding tt to the date format switches the time to use a 12 hour clock, showing an AM/PM select list accordingly :)

    opened by ghost 15
  • opens:

    opens: "embed" - always visible option, fixes #576

    Hi,

    I've added a new value for opens option - embed.

    If you choose this option, then:

    • the widget will be shown on init
    • the hide function will be disabled
    • the widget container will be appended after the HTML component it's attached to
    • the CSS styles will remove float and position absolute, to make the widget resize normally

    I know you did not plan to implement this, but maybe you could accept this PR? If you don't use it, it will not change anything.

    opened by ioleo 14
  • Adding localization support to DateRangePicker

    Adding localization support to DateRangePicker

    I have added very basic localization support to date range picker. I don't know if you already had plans to do this another way. If that's the case, please let me know what you had in mind.

    opened by vicentealencar 12
  • Always fire notify fix

    Always fire notify fix

    This would fix a state where notify() fires only if the range is present. If there is no range present ( same day selected ) or cancel has been clicked no notification would be send.

    $('input[name="daterange"]').daterangepicker({ format: 'YYYY-MM-DD', startDate: '2013-01-01', endDate: '2013-12-31' }, function notify(start, end) { 
       console.log('A date range was chosen: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
    });
    
    opened by przemyslawpluta 11
  • Upgraded Date Picking Behaviour

    Upgraded Date Picking Behaviour

    This pull request expands the way you can select dates inside of the daterangepicker.

    Changelist:

    • There is now only one state for the date picker: You have one or more selected.
    • You are no longer explicitly selecting beginning and end dates.

    New date selection flows:

    • Day A selected && Later Day B selected: Range A-B
    • Day A selected && Earlier Day B selected: Range: B-A
    • Day A && Day B selected && you select outside of range: range extended
    • Day A && Day B selected && you select endpoint A or endpoint B: single day selected
    • Day A && Day B selected && you select between A and B: single day selected

    This flow seems very natural to me and doesn't stop anyone from using the daterangepicker the same way it was originally designed.

    opened by JorinRBM 10
  • No endDate before startDate

    No endDate before startDate

    As the handling of left and right calendar was confusing our users, I tried to disable all the day's in the calendar's that are before the startDate, when it comes to the endDate selection. Hopefully this is fine?

    opened by bsa01 7
  • Added boolean

    Added boolean "showWithRanges" option for show always picker with ranges

    When ranges{} object is defined picker not shown, because show-calendar class is removed, and when selecting a range picker are hide. This is not usual for people and for avoid this i add "showWithRanges" that are default false, but if setted to true avoid the hideCalendars() on clickRange()

    opened by arturmamedov 7
  • add before show event

    add before show event

    allows you to completely reconfig the widget right before showing if needed. our form is two fields, and i needed to be able to change settings of each when activated. an example resetting the maxDate prior:

    InputStart.on('before.daterangepicker',function(e,picker){ picker.maxDate = moment(InputEnd.val(),picker.locale.format); });

    opened by bobmagicii 7
  • Allow setting options with HTML5 data attributes

    Allow setting options with HTML5 data attributes

    Sometimes it's necessary to set options without modifying the javascript. This pull request adds the flexibility to allow setting options through HTML5 data attributes.

    This also eases the transition for people coming from bootstrap datetimepicker who already have existing code which uses data attributes: http://eonasdan.github.io/bootstrap-datetimepicker/#example5

    This addresses issue #195

    opened by pawl 7
  • Bug fixing - wrong calculation of the calendar position

    Bug fixing - wrong calculation of the calendar position

    function (this.elements.outerHeight () incorrectly calculates the calendar position and returns [object Object]

    http://bugs.jquery.com/ticket/12491 http://bugs.jquery.com/ticket/12159

    opened by EduardTrayan 7
  • Add isInvalidTime to handle similar cases as isInvalidDate

    Add isInvalidTime to handle similar cases as isInvalidDate

    Added the isInvalidTime function to allow validating times etc. This was useful for a particular use case where I want to disallow the selection of a time that is within a specific range of another.

    opened by bpofficial 0
  • Fix TypeError: moment is not a function

    Fix TypeError: moment is not a function

    Hey, I have been using Vitejs and Vue3. I was getting the following error while using your npm library.

    "TypeError: moment is not a function"

    It appears when inserted into the vitejs build, the library tries to use 'moment' however it receives an object instead of moment, the object contains a 'default' property that is the actual moment method.

    I've added a check when the package is built via vitejs to check if moment is not a function and whether it has a default property, and if so, override moment with moment.default and continue as usual.

    This change fixed the error on our project.

    Thanks in advance for this awesome library.

    opened by arifsaygili 1
Releases(v3.1)
  • v3.0.5(Apr 22, 2019)

  • v3.0.4(Apr 11, 2019)

  • v3.0.3(May 22, 2018)

  • v3.0.2(May 9, 2018)

    • Don't trigger change event on input if value hasn't changed
    • Rename the calendar CSS class to avoid conflicts
    • Use :text selector instead of type="text"
    • Add missing section back to documentation site
    Source code(tar.gz)
    Source code(zip)
  • v3.0.1(Apr 30, 2018)

  • v3.0.0(Apr 29, 2018)

    • Removed Bootstrap dependency
    • Removed font icon dependency
    • Updated layout a bit to address UX complaints
    • Added minYear/maxYear settings for min/max years to include in year dropdowns
    • Renamed dateLimit to maxSpan
    • Renamed applyClass to applyButtonClasses
    • Renamed cancelClass to cancelButtonClasses
    • Updated website/documentation/examples/config generator
    • Manually merged some of the PRs with bug fixes into this version
    Source code(tar.gz)
    Source code(zip)
  • v2.1.27(Dec 12, 2017)

  • v2.1.26(Dec 12, 2017)

    • Don't add global to namespace in AMD context
    • Fixed a validation problem for certain date formats
    • Workaround to fix some issues with daylight savings time in Brazil
    • Made keyboard behavior consistent between IE11 and other browsers
    • Fixed a bug in the configuration generator
    • Calculate chosen label correctly when time picker is disabled
    • Added support for $.fn.daterangepicker.defaultOptions to set default options for all pickers on page
    Source code(tar.gz)
    Source code(zip)
  • v2.1.25(Jan 17, 2017)

    • Default date format comes from Moment.js locale instead of hardcoding MM/DD/YYYY
    • Fix bug that could result in chosenLabel not being updated properly
    • Suggested possible bug fix for time not being saved between selections when time picker is enabled
    • Avoid accidentally overwriting "background-clip" styles set by Bootstrap
    • Fix to better support unicode characters in range labels
    • Don't read data-title of table headers on hover, only dates in the body of the table
    • Other minor bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v2.1.24(Jul 15, 2016)

    • Fix bug that prevented clicking a date when the end-date text input was focused
    • Add option showCustomRangeLabel to hide the "Custom Range" predefined range label
    Source code(tar.gz)
    Source code(zip)
  • v2.1.23(Jun 30, 2016)

    • Fix #1153, #1144 where UI may break when time picker is enabled
    • Can use special characters in range names
    • Better UX when using the text inputs above the calendars
    Source code(tar.gz)
    Source code(zip)
  • v2.1.22(Jun 16, 2016)

  • v2.1.21(May 31, 2016)

  • v2.1.20(May 25, 2016)

    • Fix more deprecation warnings from moment.js
    • RTL support in locale option
    • Don't display the month after maxDate on the right calendar when linkedCalendars is enabled
    • singleDatePicker no longer hides the time icon next to time pickers
    • Improved the AMD/browserify module definition
    • Add weekLabel option to the locale option example on website
    • Add .form-control class to inputs within the picker to better match Bootstrap styling
    • Apply in-range class to the date you're hovering over with your mouse
    • Treat buttons the same as inputs and show the picker when they gain focus
    • Add isCustomDate option that allows you to apply custom CSS classes to individual dates
    Source code(tar.gz)
    Source code(zip)
  • v2.1.19(Mar 9, 2016)

  • v2.1.18(Feb 22, 2016)

    Changelog:

    • options.template can be a compiled jQuery object in addition to a string
    • SASS version of the stylesheet file added
    • Fix bug where the predefined range label passed to callback functions was possibly incorrect when autoApply is enabled
    • Add showISOWeekNumbers option to display ISO week numbers instead of localized week numbers next to each calendar row
    • Add alwaysShowCalendars option to always allow selection of a custom range, not only after clicking "Custom Range" button
    Source code(tar.gz)
    Source code(zip)
  • v2.1.17(Dec 17, 2015)

  • v2.1.16(Dec 17, 2015)

  • v2.1.15(Dec 17, 2015)

  • v2.1.14(Dec 11, 2015)

    • Time selection bug fixes
    • Time selected on right calendar is preserved when changing the date selection
    • Return DateRangePicker object in factory for AMD/webpack
    • Fix variable leaked to global
    Source code(tar.gz)
    Source code(zip)
  • v2.1.13(Oct 17, 2015)

    • Support unicode characters in range names
    • Maintain correct position of the picker when window is resized
    • Ignore partially typed dates in text input when the input is too short or invalid
    • Fix time picker bug when start and end dates fall on the same day
    Source code(tar.gz)
    Source code(zip)
  • v2.1.12(Oct 8, 2015)

    There are no changes in this release. I'm bumping the version number to fix an issue with one of the CDNs that automatically hosts this library due to a typo in a previous release tag.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.14(Oct 7, 2015)

    Removed the timezone option, which has not functioned correctly since its inception. I recommend managing time zones in your application, or through the moment object, where you can set a global time zone. http://momentjs.com/timezone/docs/

    Source code(tar.gz)
    Source code(zip)
  • v2.0.13(Oct 6, 2015)

  • v2.0.12(Sep 30, 2015)

  • v2.0.11(Sep 16, 2015)

  • v2.0.10(Sep 16, 2015)

    • Have the widget expand in the direction of the "opens" setting when clicking "Custom Range"
    • Ignore mouse movements when editing the text boxes within the widget, so your work doesn't get overwritten when moving from the start to the end box
    • Update the element value if you programmatically call setStartDate or setEndDate while the UI is hidden
    • Remove some cruft
    Source code(tar.gz)
    Source code(zip)
  • v2.0.8(Aug 10, 2015)

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!

rome Customizable date (and time) picker. Opt-in UI, no jQuery! Rome wasn't built in a day. Browser support includes every sane browser and IE7+. Demo

Nicolás Bevacqua 2.9k Dec 10, 2022
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS

Pikaday A refreshing JavaScript Datepicker Lightweight (less than 5kb minified and gzipped) No dependencies (but plays well with Moment.js) Modular CS

null 7.9k Jan 4, 2023
Gantt Gantt Gantt Timeline Schedule Calendar [ javascript gantt, js gantt, projects gantt, timeline, scheduler, gantt timeline, reservation timeline, react gantt, angular gantt, vue gantt, svelte gantt, booking manager ]

Gantt Gantt Gantt Timeline Schedule Calendar [ javascript gantt, js gantt, projects gantt, timeline, scheduler, gantt timeline, reservation timeline, react gantt, angular gantt, vue gantt, svelte gantt, booking manager ]

neuronet.io 2.1k Dec 30, 2022
JavaScript Date Range, Date and Time Picker Component

Date Range Picker This date range picker component creates a dropdown menu from which a user can select a range of dates. I created it while building

Dan Grossman 10.6k Dec 29, 2022
A JavaScript component that is a date & time range picker, no need to build, no dependencies except Moment.js, that is based on Dan Grossman's bootstrap-daterangepicker.

vanilla-datetimerange-picker Overview. A JavaScript component that is a date & time range picker, no need to build, no dependencies except Moment.js,

null 22 Dec 6, 2022
A date picker web component, and spiritual successor to duet date picker

<date-picker> A date picker web component, based on duet date picker, except authored with Lit and using shadow DOM. This is a work in progress. Todo:

Nick Williams 25 Aug 3, 2022
Nepali Multi Date Picker for jQuery. Supports both single date selections and multiple date selection.

Nepali Multi Date Picker A simple yet powerful date picker based in Nepali calendar. Supports both single date selections and multiple date selection.

Sanil Shakya 4 May 23, 2022
Colr Pickr, a vanilla JavaScript color picker component built with SVGs, with features like saving colors. Similar design to the chrome-dev-tools color picker.

Colr Pickr Colr Pickr, a vanilla JavaScript color picking component built with SVGs, with features like saving colors. Similar design to the chrome-de

TEK 27 Jun 27, 2022
A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles

range-slider-input A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles. Ex

Utkarsh Verma 42 Dec 24, 2022
Generate release notes from git commit history either commit range or tag range.

Would you like to support me? Release Notes Generate release notes from git commit history either commit range or tag range. App Store Template Change

Numan 6 Oct 8, 2022
Tool Cool Color Picker is a color picker library written in typescript and using web component technologies.

Tool Cool Color Picker Tool Cool Color Picker is a color picker library written in typescript and using web component technologies. Check out the demo

Tool Cool 13 Oct 23, 2022
Simple date and time picker in vanilla javascript

simplepicker Simple datetime picker in vanilla javascript. This project is mostly based on material-datetime-picker, but without it relying on externa

Priyank Patel 51 Jul 18, 2022
The mobile-friendly, responsive, and lightweight jQuery date & time input picker.

pickadate The mobile-friendly, responsive, and lightweight jQuery date & time input picker. To get started, check out the: Homepage - Date picker - Ti

null 7.7k Jan 3, 2023
:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!

rome Customizable date (and time) picker. Opt-in UI, no jQuery! Rome wasn't built in a day. Browser support includes every sane browser and IE7+. Demo

Nicolás Bevacqua 2.9k Dec 10, 2022
A simplified jQuery date and time picker

jSunPicker A simplified jQuery date and time picker Why another Date picker? There are numerous date, time pickers out there. However, each of those l

null 1 May 31, 2022
CalendarPickerJS - A minimalistic and modern date-picker component/library 🗓️👨🏽‍💻 Written in Vanilla JS

CalendarPickerJS The simple and pretty way to let a user select a day! Supports all major browser. Entirely written in Vanilla JavaScript with no depe

Mathias Picker 15 Dec 6, 2022
A super-lightweight, highly configurable, cross-browser date / time picker jQuery plugin

Zebra Datepicker A super-lightweight, highly configurable, cross-browser date/time picker jQuery plugin Zebra_Datepicker is a small yet and highly con

Stefan Gabos 391 Dec 29, 2022
Bootstrap Persian/Gregorian Date Time Picker

MD.BootstrapPersianDateTimePicker Bootstrap 5+ Persian And Gregorian Date Time Picker Major changes: Using Bootstrap 5 jQuery Removed Rewrite all code

Mohammad Dayyan 305 Nov 23, 2022
Reusable date picker component for React

React DayPicker DayPicker is a reusable date picker component for React. $ npm install react-day-picker@next Beta version ⚠️ This branch is for the ne

Giampaolo Bellavite 4.8k Dec 28, 2022
A jQuery Plug-in to select the time with a clock inspired by the Android time picker.

Clock Timepicker Plugin for jQuery See a demo here A free jQuery Plug-in to select the time with a clock inspired by the Android time picker. This plu

Andy 51 Dec 22, 2022