Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Date range picker component for Twitter Bootstrap

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README.md
Octocat-spinner-32 date.js
Octocat-spinner-32 daterangepicker.css
Octocat-spinner-32 daterangepicker.js
Octocat-spinner-32 examples.html
README.md

Date Range Picker for Twitter Bootstrap

Improvely.com

This date range picker component for Twitter Bootstrap 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.

If invoked with no options, it will present two calendars to choose a start and end date from. Optionally, you can provide a list of date ranges the user can select from instead of choosing dates from the calendars. If attached to a text input, the selected dates will be inserted into the text box. Otherwise, you can provide a custom callback function to receive the selection.

View a demo

Usage

This component relies on Twitter Bootstrap, Datejs and jQuery.

Basic usage:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="date.js"></script>
<script type="text/javascript" src="daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap.css" />
<link rel="stylesheet" type="text/css" href="daterangepicker.css" />

<script type="text/javascript">
$(document).ready(function() {
  $('input[name="daterange"]').daterangepicker();
});
</script>

Additional options allow:

  • Custom callback handler called when the date range selection is made
  • Setting initial start and end dates for the calendars
  • Overriding all labels in the interface with localized text
  • Bounding the minimum and maximum selectable dates
  • Starting the calendar week on any day of week
  • Overriding the direction the dropdown expands (left/right of element it's attached to)
  • Setting the date format string for parsing and printing dates
  • Showing week numbers
  • Maximum selectable range (i.e. 3 days, 1 week, 12 months)
  • Month and year dropdowns

Syntax for all the options can be found in the examples.html file.

License

This code is made available under the same license as Twitter Bootstrap. Date.js is included in this repository for convenience. It is available under the MIT license.

Copyright 2012 Dan Grossman

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Something went wrong with that request. Please try again.