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 🙏

© 2025 – Pkg Stats / Ryan Hefner

d8js

v1.1.2

Published

Ultra-lightweight date & time formatting utility for JavaScript, React, Vue, Angular. <1.5KB, zero dependencies.

Readme

d8js

<1.5KB · Zero deps · React, Vue, Angular, Node, Vanilla

Named date formats with smart locale & relative time.

Formats

| String | Output | | :------- | :--------------------------- | | short | 11/11/2025 | | medium | Nov 11, 2025 | | long | November 11, 2025 | | full | Wednesday, November 11, 2025 | | iso | 2025-11-11 | | time | 3:45 PM | | datetime | 11/11/2025, 3:45 PM | | relative | 1 day ago | | ago | 5m, 3h, 2d | | filename | 2025-11-11_22-51 | | input | 2025-11-11 |

Usage

Vanilla / Node

import { dateObj } from "d8js";

dateObj("2025-11-11", "short"); // 11/11/2025
dateObj("2025-11-11", "medium"); // Nov 11, 2025
dateObj("2025-11-11", "long"); // November 11, 2025
dateObj("2025-11-11", "full"); // Tuesday, November 11, 2025
dateObj("2025-11-11", "iso"); // 2025-11-11
dateObj("2025-11-11T22:46", "time"); // 10:46 PM
dateObj("2025-11-11T22:46", "datetime"); // 11/11/2025, 10:46 PM

// Relative time examples
dateObj(Date.now() - 24 * 60 * 60 * 1000, "relative"); // yesterday
dateObj(Date.now() + 2 * 24 * 60 * 60 * 1000, "relative"); // in 2 days

// Ago format
dateObj(Date.now() - 5 * 60 * 1000, "ago"); // 5m
dateObj(Date.now() - 2 * 60 * 60 * 1000, "ago"); // 2h
dateObj(Date.now() - 3 * 24 * 60 * 60 * 1000, "ago"); // 3d

dateObj("2025-11-11T22:46", "filename"); // 2025-11-11_22-46
dateObj("2025-11-11", "input"); // 2025-11-11
dateObj(new Date(Date.now() - 5 * 1000), "ago"); // "5 seconds ago"
dateObj(new Date(), "medium"); // "Nov 11, 2025"

React

import { dateObj } from "d8js";

function App() {
  return (
    <>
      <p>{dateObj(new Date(), "short")}</p>
    </>
  );
}

export default App;

Vue

<script setup>
  import { dateObj } from "d8js";
</script>

<template>
  <p>{{ dateObj("2025-11-11", "medium") }}</p>
</template>

Angular

Note: DateObjPipe is a custom Angular pipe that formats dates using the dateObj() npm package.

Create a custom pipe: date-obj.pipe.ts

import { Pipe, PipeTransform } from "@angular/core";
import { dateObj, FormatType } from "d8js";

@Pipe({ name: "dateObj" })
export class DateObjPipe implements PipeTransform {
  transform(
    value: Date | string | number,
    formate: FormatType = "medium",
    locale?: string
  ): string {
    return dateObj(value, formate, locale);
  }
}

In TS file

import { DateObjPipe } from './date-obj-pipe';

@Component({
  imports: [DateObjPipe],
})

In HTML file

<p>{{ '2025-11-12' | dateObj:'relative' }}</p>

Links

linkedin