npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mini-dayjs

v1.0.1

Published

A lightweight date manipulation library similar to Dayjs.

Readme

MiniDayjs

MiniDayjs is a lightweight JavaScript library for date manipulation, inspired by Dayjs. It provides a simple and efficient API to handle common date operations such as formatting, adding, subtracting, and comparing dates, all while keeping the bundle size small.

Installation

You can install MiniDayjs via npm:

npm install mini-dayjs

Alternatively, if you're using Yarn:

yarn add mini-dayjs

Usage

Here's how you can start using MiniDayjs in your project:

Basic Date Creation

You can create a MiniDayjs instance for the current date or a specific date:

const dayjs = require('mini-dayjs');

// Create a new instance for the current date
const now = dayjs();

// Create a new instance for a specific date
const specificDate = dayjs('2025-01-01');

console.log(now.format('YYYY-MM-DD'));  // Output: Current date in "YYYY-MM-DD" format
console.log(specificDate.format('YYYY-MM-DD'));  // Output: 2025-01-01

Date Formatting

You can format dates using the format() method. Here's an example:

const formattedDate = dayjs('2025-01-01').format('MMMM DD, YYYY');
console.log(formattedDate);  // Output: January 01, 2025

Supported Format Tokens

  • YYYY– Full year (e.g., 2025)
  • YY– Short year (e.g., 25)
  • MMMM– Full month name (e.g., January)
  • MMM– Abbreviated month name (e.g., Jan)
  • DD– Day of the month (e.g., 01)

Adding and Subtracting Time

You can easily add or subtract time (e.g., days, months, years) to/from a date:

const futureDate = dayjs().add(3, 'day');  // Adds 3 days
const pastDate = dayjs().subtract(2, 'month');  // Subtracts 2 months

console.log(futureDate.format('YYYY-MM-DD'));  // Output: 3 days from now
console.log(pastDate.format('YYYY-MM-DD'));  // Output: 2 months ago

Comparing Dates

You can compare dates using isBefore() and isAfter():

const date1 = dayjs('2025-01-01');
const date2 = dayjs('2025-01-02');

console.log(date1.isBefore(date2));  // Output: true
console.log(date1.isAfter(date2));   // Output: false

Time Ago (Relative Time)

You can display the relative time (e.g., "2 days ago") using the fromNow() method:

const pastDate = dayjs('2025-01-01');
console.log(pastDate.fromNow());  // Output: "X days ago" (depends on the current date)

Methods Overview

Here’s a quick overview of the main methods available in MiniDayjs:

  • add(amount, unit): Adds a specified amount of time (e.g., days, months, years).
  • subtract(amount, unit): Subtracts a specified amount of time.
  • format(formatString): Formats the date in a human-readable format.
  • isBefore(date): Checks if the current date is before the specified date.
  • isAfter(date): Checks if the current date is after the specified date.
  • fromNow(): Returns the relative time from the current date (e.g., "2 days ago").
  • toDate(): Returns the underlying JavaScript Date object.

Example

Here’s a full example that demonstrates creating a MiniDayjs instance, formatting dates, adding/subtracting time, and comparing dates:

const dayjs = require('mini-dayjs');

// Create a new instance for today
const today = dayjs();

// Create a new instance for New Year's Day 2025
const newYear = dayjs('2025-01-01');

// Add 5 days to the current date
const fiveDaysLater = today.add(5, 'day');
console.log(fiveDaysLater.format('YYYY-MM-DD'));  // Output: 5 days from today

// Subtract 3 months from the current date
const threeMonthsAgo = today.subtract(3, 'month');
console.log(threeMonthsAgo.format('YYYY-MM-DD'));  // Output: 3 months ago

// Compare two dates
console.log(newYear.isBefore(today));  // Output: true (if New Year's Day 2025 is before today)
console.log(newYear.isAfter(today));   // Output: false

// Show relative time from now
console.log(newYear.fromNow());  // Output: "1 year ago" (depends on the current date)