Skip to content

Quick Start

  1. Install

    Terminal window
    npm install date-wiz
  2. Import what you need

    import { wiz, format, getRelativeTime, parse, smartFormat } from 'date-wiz';
  3. Format a date

    format(new Date(), 'DD MMMM YYYY') // "15 March 2026"
    format(new Date(), 'DD MMMM', 'bn-BD') // "১৫ মার্চ"
    format(new Date(), 'hh:mm A') // "02:30 PM"
    format(new Date(), 'LLL') // "March 15, 2026 at 2:30 PM"
  4. Get relative time

    getRelativeTime(twoDaysAgo) // "2 days ago"
    getRelativeTime(twoDaysAgo, { precision: 2 }) // "2 days, 4 hours ago"
    getRelativeTime(nextWeek, { locale: 'fr' }) // "dans 7 jours"
  5. Use the chainable API

    const deadline = wiz(new Date())
    .add(3, 'businessDays')
    .setHour(17)
    .format('LLL');
    // → "March 19, 2026 at 5:00 PM"

import { getRelativeTime } from 'date-wiz';
const launch = new Date('2026-12-31T00:00:00');
console.log(getRelativeTime(launch));
// → "in 9 months"
import { smartFormat } from 'date-wiz';
posts.map(post => ({
...post,
displayDate: smartFormat(post.createdAt),
// → "Today at 9:42 AM" | "Yesterday at 3:00 PM" | "Oct 12, 2022"
}));
import { addBusinessDays } from 'date-wiz';
const slaDeadline = addBusinessDays(new Date(), 5, {
holidays: ['2026-12-25', '2026-01-01'],
});
import { parse, format } from 'date-wiz';
const d = parse(userInput); // "next_monday", "+2d", "15-05-2024" — all work
if (d) {
console.log(format(d, 'LL')); // "March 16, 2026"
}