Datetimepicker logo Datetimepicker

Init

DateTime picker.

Installation

Browser

<script src="/path/to/datetimepicker.min.js"></script>

unpkg CDN:

//unpkg.com/@circunspecter/datetimepicker@latest/dist/datetimepicker.min.js

npm

npm install @circunspecter/datetimepicker

Basic usage

let datetimepicker = new Datetimepicker();

datetimepicker.addListener('dtp:action:click', (e) => {
  if (e.detail.action == 'accept') {
    let dateTime = e.detail.dateTime.toLocaleDateString(undefined, {
      year: 'numeric', month: 'long', day: 'numeric',
      hour: '2-digit', minute: '2-digit',
      hour12: true
    });
    document.getElementById('selected-datetime').textContent = dateTime;
  }
});

nothing selected