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

nano-date-js

v20.1.1

Published

A high-performance, lightweight Angular date manipulation and formatting library. A modern, zero-dependency alternative to Moment.js designed for precision and speed.

Readme

Nano-Date-Js

This project was generated using Angular CLI version 20.0.0.


Packed & UnPacked Size

  • package size: 9.9 kB
  • unpacked size: 45.3 kB

Documentation

# 📅 Nano Dates Js

A lightweight, developer-friendly date utility library built with **Angular 20**, inspired by Moment.js.  
It provides powerful date creation, manipulation, formatting, comparison, and duration handling in a clean and modular way.

---

## 🚀 Features

- ✅ Create dates from multiple sources (string, timestamp, Date, UTC, Unix)
- ✅ Easy getters (year, month, day, hours, etc.)
- ✅ Flexible date formatting
- ✅ Immutable-style manipulation (add, subtract, startOf, endOf)
- ✅ Rich comparison utilities
- ✅ Accurate date difference calculations
- ✅ Duration handling
- ✅ UTC & Local mode support
- ✅ Static utilities (min, max, now)
- ✅ Method chaining support

---

## 📦 Installation

```bash
npm install nano-date-js
```

📘 Usage

import { nanoDate } from "nano-date-js";

🧱 API Reference


1. Creating Dates

// Current date/time
const now = nanoDate();

// From string
const fromString = nanoDate("2024-01-15");

// From timestamp (milliseconds)
const fromTimestamp = nanoDate(1705315200000);

// From Date object
const fromDate = nanoDate(new Date(2024, 0, 15));

// Clone from another instance
const cloned = nanoDate(fromString);

// UTC mode
const utcNow = nanoDate.utc();

// Unix timestamp (seconds)
const unixTime = nanoDate.unix(1705315200);

// Invalid date
const invalid = nanoDate("invalid-date");
invalid.isValid(); // false

2. Getters

const date = nanoDate("2024-01-15 14:30:45");

date.year();
date.month(); // 0-11
date.date();
date.day(); // 0-6
date.hours();
date.minutes();
date.seconds();
date.quarter();

3. Formatting

const date = nanoDate("2024-01-15 14:30:45");

date.format("YYYY-MM-DD");
date.format("DD/MM/YYYY");
date.format("MMM DD, YYYY");
date.format("MMMM Do, YYYY");

date.format("HH:mm:ss");
date.format("hh:mm:ss A");
date.format("h:mm a");

date.format("dddd");
date.format("ddd");

date.format("Z");
date.format("ZZ");

date.format("dddd, MMMM Do YYYY, h:mm:ss a");

4. Manipulation

const date = nanoDate("2024-01-15");

// Add
date.add(1, "week");
date.add(1, "month");
date.add(1, "year");
date.add(5, "hours");

// Chain
date.add(1, "month").add(5, "days").add(3, "hours");

// Subtract
date.subtract(1, "week");
date.subtract(1, "month");

// Start of
date.startOf("year");
date.startOf("month");
date.startOf("week");
date.startOf("day");
date.startOf("hour");

// End of
date.endOf("year");
date.endOf("month");
date.endOf("week");
date.endOf("day");

5. Comparison

const d1 = nanoDate("2024-01-15");
const d2 = nanoDate("2024-02-20");

d1.isBefore(d2);
d2.isAfter(d1);
d1.isSame(d2);

d1.isSameOrBefore(d2);
d2.isSameOrAfter(d1);

const target = nanoDate("2024-02-01");
target.isBetween(d1, d2);
target.isBetween(d1, d2, "[]"); // inclusive

6. Difference

const start = nanoDate("2024-01-15");
const end = nanoDate("2024-02-20");

end.diff(start, "days");
end.diff(start, "weeks");
end.diff(start, "months");
end.diff(start, "years");

end.diff(start, "milliseconds");

// Floating result
end.diff(start, "months", true);

7. Duration

const d1 = nanoDate.duration(3600000);

const d2 = nanoDate.duration({
  hours: 2,
  minutes: 30,
  seconds: 15,
});

d2.asHours();
d2.asDays();

d2.hours();
d2.minutes();
d2.days();

// Use with nanoDate
nanoDate().add(d2.asHours(), "hours");

8. UTC & Local Mode

const local = nanoDate("2024-01-15T12:00:00");
const utc = nanoDate.utc("2024-01-15T12:00:00");

// Convert
local.utc();
utc.local();

// Check mode
local._isUTC;
utc._isUTC;

9. Static Methods

nanoDate.now();

const dates = [
  nanoDate("2024-01-15"),
  nanoDate("2024-02-20"),
  nanoDate("2024-01-01"),
];

nanoDate.max(...dates);
nanoDate.min(...dates);

nanoDate.unix(1705315200);

10. Chaining

nanoDate("2024-01-15")
  .add(1, "month")
  .add(5, "days")
  .startOf("week")
  .subtract(2, "hours")
  .utc()
  .format("dddd, MMMM Do YYYY, HH:mm [UTC]");

⚡ Why Nano Dates?

  • Lightweight alternative to Moment.js
  • Angular-first architecture
  • Clean API with chaining support
  • Easy to extend and customize

🛠 Built With

  • Angular 20
  • TypeScript

📄 License

MIT License