EasyEpoch

A lightweight datetime picker in vanilla JavaScript with zero dependencies.

npm version MIT License
$ npm install easyepoch
Examples

Theming

Switch between built-in light and dark themes at runtime with setTheme().

Current theme: dark
const picker = new EasyEpoch({ theme: 'dark' }); // Switch at runtime picker.setTheme('light'); picker.setTheme('dark'); // Or pass a custom theme object picker.setTheme({ bg: '#0a0a0a', primary: '#ff6b6b', secondary: '#ffd93d', accent: '#ff6b6b', text: '#f0f0f0', });

Basic Usage

Create a picker, open it with a button, and listen for the selected date.

Click the button to select a date...
const picker = new EasyEpoch(); picker.on('submit', (date, readableDate) => { console.log(readableDate); // "7th February 2026 3:30 PM" }); document.querySelector('button').addEventListener('click', () => { picker.open(); });

Bound to Element

Attach the picker to a specific container element instead of the body.

const picker = new EasyEpoch('#my-container', { zIndex: 10 }); picker.on('submit', (date, readableDate) => { document.querySelector('input').value = readableDate; });

Compact Mode

Hide the large date display header for a smaller, more compact layout.

Click the button to try compact mode...
const picker = new EasyEpoch({ compactMode: true }); picker.on('submit', (date, readableDate) => { console.log(readableDate); });

Date Only (No Time)

Disable the time picker section when you only need a date.

Click the button to pick a date without time...
const picker = new EasyEpoch({ disableTimeSection: true }); picker.on('submit', (date, readableDate) => { console.log(readableDate); });

Pre-selected Date

Initialize the picker with a specific date already selected.

Opens with Dec 31, 2026 pre-selected...
const picker = new EasyEpoch({ selectedDate: new Date(2026, 11, 31, 23, 59) }); picker.on('submit', (date, readableDate) => { console.log(readableDate); });

Multiple Pickers

Use two separate picker instances for a start and end date range.

const startPicker = new EasyEpoch('#start-container'); const endPicker = new EasyEpoch('#end-container'); startPicker.on('submit', (date, readableDate) => { document.querySelector('#start').value = readableDate; }); endPicker.on('submit', (date, readableDate) => { document.querySelector('#end').value = readableDate; });

Event Handling

Listen to both submit and close events from the picker.

Event log appears here...
picker.on('submit', (date, readableDate) => { log.append(`Selected: ${readableDate}`); }); picker.on('close', () => { log.append('Picker was closed/cancelled'); });