Convert Figma logo to code with AI

Eonasdan logotempus-dominus

A powerful Date/time picker widget.

7,152
4,406
7,152
19

Top Related Projects

16,122

lightweight, powerful javascript datetimepicker with no dependencies

JavaScript Date Range, Date and Time Picker Component

8,000

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS

jQuery Plugin Date and Time Picker

⚠️ [Deprecated] No longer maintained. A simple jQuery datepicker plugin.

Quick Overview

Tempus Dominus is a powerful and flexible date and time picker library for web applications. It provides a customizable UI for selecting dates, times, or both, with support for various frameworks including vanilla JavaScript, Bootstrap 4/5, and Moment.js.

Pros

  • Highly customizable with numerous options and configurations
  • Supports multiple frameworks and can be used with or without dependencies
  • Responsive design that works well on both desktop and mobile devices
  • Extensive documentation and active community support

Cons

  • Learning curve can be steep for advanced customizations
  • Some users report occasional performance issues with large datasets
  • Dependency on Moment.js (optional but recommended) adds to the overall bundle size
  • Limited built-in localization options, requiring additional setup for non-English languages

Code Examples

  1. Basic date picker initialization:
const picker = new tempusDominus.TempusDominus(document.getElementById('datetimepicker1'));
  1. Configuring date picker options:
const picker = new tempusDominus.TempusDominus(document.getElementById('datetimepicker2'), {
  display: {
    components: {
      decades: true,
      year: true,
      month: true,
      date: true,
      hours: false,
      minutes: false,
      seconds: false
    },
    theme: 'light'
  }
});
  1. Event handling:
const element = document.getElementById('datetimepicker3');
const picker = new tempusDominus.TempusDominus(element);

element.addEventListener(tempusDominus.Namespace.events.change, (e) => {
  console.log(e.detail.date);
});

Getting Started

  1. Include the Tempus Dominus CSS and JS files in your HTML:
<link href="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.7/dist/css/tempus-dominus.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.7/dist/js/tempus-dominus.min.js"></script>
  1. Create an input element and initialize the date picker:
<input type="text" id="datetimepicker" />
<script>
  const picker = new tempusDominus.TempusDominus(document.getElementById('datetimepicker'));
</script>

This will create a basic date and time picker. You can further customize it by passing options to the constructor or using the provided API methods.

Competitor Comparisons

16,122

lightweight, powerful javascript datetimepicker with no dependencies

Pros of flatpickr

  • Lightweight and fast, with a smaller file size
  • More extensive browser support, including older versions
  • Highly customizable with a wide range of options and plugins

Cons of flatpickr

  • Less comprehensive date and time handling compared to Tempus Dominus
  • Fewer built-in features for complex date/time scenarios
  • Limited support for localization and internationalization out of the box

Code Comparison

flatpickr:

flatpickr("#myDatePicker", {
  enableTime: true,
  dateFormat: "Y-m-d H:i",
});

Tempus Dominus:

new tempusDominus.TempusDominus(document.getElementById('myDatePicker'), {
  display: {
    components: {
      clock: true,
    },
    format: 'yyyy-MM-dd HH:mm'
  }
});

Both libraries offer easy-to-use initialization, but Tempus Dominus provides more granular control over display components. flatpickr's syntax is more concise, while Tempus Dominus offers a more object-oriented approach with nested options.

JavaScript Date Range, Date and Time Picker Component

Pros of daterangepicker

  • Lightweight and focused on date range selection
  • Easy to integrate with Bootstrap and jQuery
  • Extensive documentation and examples

Cons of daterangepicker

  • Limited to date and time selection functionality
  • Requires jQuery dependency
  • Less frequent updates and maintenance

Code Comparison

daterangepicker:

$('input[name="daterange"]').daterangepicker({
    opens: 'left',
    startDate: moment().startOf('hour'),
    endDate: moment().startOf('hour').add(32, 'hour')
});

tempus-dominus:

const picker = new tempusDominus.TempusDominus(document.getElementById('datetimepicker'), {
    display: {
        sideBySide: true,
        components: {
            calendar: true,
            date: true,
            month: true,
            year: true,
            decades: true,
            clock: true,
            hours: true,
            minutes: true,
            seconds: true
        }
    }
});

Summary

daterangepicker is a lightweight solution for date range selection, ideal for projects using Bootstrap and jQuery. It's easy to implement but has limited functionality beyond date ranges. tempus-dominus offers a more comprehensive datetime picker with additional features and customization options, but may be overkill for simple date range selection needs. The choice between the two depends on the specific requirements of your project and the desired level of functionality.

8,000

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS

Pros of Pikaday

  • Lightweight and minimalistic, with a smaller file size
  • No external dependencies, making it easier to integrate
  • Simple API and straightforward configuration options

Cons of Pikaday

  • Limited feature set compared to Tempus Dominus
  • Less customization options for advanced use cases
  • Lacks built-in support for time selection and range picking

Code Comparison

Pikaday:

var picker = new Pikaday({
    field: document.getElementById('datepicker'),
    format: 'D MMM YYYY',
    onSelect: function(date) {
        console.log(date);
    }
});

Tempus Dominus:

new tempusDominus.TempusDominus(document.getElementById('datetimepicker'), {
    display: {
        components: {
            clock: true,
            date: true,
            month: true,
            year: true,
        },
        format: 'DD MMM YYYY HH:mm'
    },
    hooks: {
        inputFormat: (context, date) => moment(date).format('DD MMM YYYY HH:mm')
    }
});

jQuery Plugin Date and Time Picker

Pros of datetimepicker

  • Lightweight and simple to use
  • Supports a wide range of date and time formats
  • Extensive customization options for appearance and behavior

Cons of datetimepicker

  • Less active development and maintenance
  • Limited modern browser features and accessibility support
  • Fewer built-in localization options

Code Comparison

datetimepicker:

$('#datetimepicker').datetimepicker({
  format: 'Y-m-d H:i',
  inline: true,
  lang: 'en'
});

tempus-dominus:

new tempusDominus.TempusDominus(document.getElementById('datetimepicker'), {
  display: {
    inline: true,
    components: {
      date: true,
      month: true,
      year: true,
      clock: true
    }
  },
  localization: {
    format: 'yyyy-MM-dd HH:mm'
  }
});

Both libraries offer datetime picking functionality, but tempus-dominus provides a more modern approach with better TypeScript support, accessibility features, and active development. datetimepicker is simpler to set up and use, making it suitable for smaller projects or those with basic requirements. tempus-dominus offers more robust features and customization options, making it a better choice for larger, more complex applications that require advanced functionality and ongoing support.

⚠️ [Deprecated] No longer maintained. A simple jQuery datepicker plugin.

Pros of Datepicker

  • Lightweight and simple, with a smaller file size
  • Easy to use and integrate, with minimal setup required
  • Supports a wide range of browsers, including older versions

Cons of Datepicker

  • Limited features compared to Tempus Dominus
  • Lacks advanced time selection options
  • No built-in localization support

Code Comparison

Datepicker initialization:

$('.datepicker').datepicker({
  format: 'yyyy-mm-dd',
  autoclose: true
});

Tempus Dominus initialization:

new tempusDominus.TempusDominus(document.getElementById('datetimepicker'), {
  display: {
    components: {
      clock: false
    }
  }
});

Both libraries offer straightforward initialization, but Tempus Dominus provides more configuration options out of the box. Datepicker focuses on simplicity, while Tempus Dominus offers greater flexibility and features.

Datepicker is ideal for projects requiring basic date selection functionality with minimal overhead. Tempus Dominus is better suited for applications needing advanced date and time picking capabilities, localization support, and extensive customization options.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ko-fi

Paid support only

Please note that I'm moving on to other projects. New issues will need to be sponsored. This can be done via BountySource or my other donation links. Please reach out to me first so we can discuss the terms. Thank you for your years of support.

Tempus Dominus Date/Time Picker v6.9.4

Tempus Dominus is a powerful and robust date time picker for javascript. Version 6 is another major rewrite over the previous version. V6 is written with modern browsers in mind and is written in typescript. Bootstrap, momentjs and jQuery are no longer required dependencies. Popper2 is all that is required for the picker to position correctly. If you still require jQuery (seriously, you should move off that asap) there's a jQuery provider that wraps the native js functions.

Developers

Building

Run npm i to install needed packages.

The docs folder contains the generated documentation site, don't modify this directly as it will be overwritten on build. The dist folder contains the built js/css files.

Running

You can run npm run serve which will start a web server. Navigate to http://localhost:3001/ to view the docs.

Watching for changes

Do not run npm run serve at the same time.

Run npm start. This runs web server, the build and watchers for the docs, styles, and typescript.

Where do you use this?

I'd love to know if your public site is using this plugin and list your logo on the documentation site. Leave create a discussion and let me know.

Priority support is available at an hourly rate.

If you have an urgent request, bug or need installation help, please contact in the discord server.

NPM DownloadsLast 30 Days