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

time-ago-ts

v1.0.2

Published

Zero-dependency TypeScript date utility library with 50+ tree-shakeable helpers: toTimeAgo, isBusinessDay, daysRemaining, formatting, fiscal year, Julian day, and more. Inspired by date_formatter_codespark on pub.dev.

Readme

time-ago-ts

Zero-dependency TypeScript library with 50+ Date helpers — toTimeAgo, business days, formatting, countdown, and more.

npm version npm downloads bundle size License: MIT TypeScript zero deps

Built with ❤️ by Naresh Kumar Lokrey

Why time-ago-ts?

Raw JS:

const diff = Date.now() - new Date('2026-05-29').getTime()
// messy

With time-ago-ts:

import { toTimeAgo, daysRemaining } from 'time-ago-ts'
toTimeAgo(new Date(Date.now() - 1000 * 60 * 12)) // '12m ago'
daysRemaining(new Date('2026-06-10')) // 'N days left'

Installation

npm install time-ago-ts

yarn add time-ago-ts

pnpm add time-ago-ts

Quick Start

import { toTimeAgo, isBusinessDay, toIsoDateString, daysRemaining, toJulianDay } from 'time-ago-ts'

toTimeAgo(new Date())
isBusinessDay(new Date())
toIsoDateString(new Date())
daysRemaining(new Date(Date.now() + 86400000))
toJulianDay(new Date())

Usage (Node & React)

  • Node (CommonJS):
const ds = require('time-ago-ts')
console.log(ds.toTimeAgo(new Date()))
  • ESM / React (recommended for bundlers and tree-shaking):
import { toTimeAgo, toIsoDateString } from 'time-ago-ts'
console.log(toTimeAgo(new Date()))
console.log(toIsoDateString(new Date()))

Your package ships both ESM (dist/index.mjs) and CJS (dist/index.js) entries so it works in Node and browser bundlers (Create React App, Vite, Webpack) without extra config.

API Reference

Relative Time

toTimeAgo(date: Date, options?: { short?: boolean }) // '12m ago'

Calendar Flags

isToday(date: Date) // boolean
isYesterday(date: Date)
isTomorrow(date: Date)
isThisWeek(date: Date)

Time of Day

isMorning(date: Date)
isAfternoon(date: Date)
isEvening(date: Date)
isNight(date: Date)

Month & Quarter Flags

isFirstDayOfMonth(date: Date)
isLastDayOfMonth(date: Date)
daysInMonth(date: Date)

Business Days

isBusinessDay(date: Date)
addBusinessDays(date: Date, days: number)

Boundaries

startOfDay(date)
endOfDay(date)
startOfWeek(date)
endOfWeek(date)

Date Math

nextDay(date)
previousDay(date)
copyWith(date, fields)

Comparison

isSameDay(a,b)
isSameWeek(a,b)

Formatting

toDayAndMonth(date)
toFullHumanDate(date)
toTime12Hour(date)

Countdown

daysRemaining(date)
hoursRemaining(date)

Holiday & Fiscal

isPublicHoliday(date, holidays[])
toFiscalYear(date, { fiscalYearStartMonth?: number })

Julian Day

toJulianDay(date)
fromJulianDay(jd)

Zero Dependencies

time-ago-ts is implemented with pure TypeScript and uses no runtime dependencies, making it small and easy to include.

Inspired By

Inspired by the Flutter package date_formatter_codespark by Katayath Sai Kiran

License

MIT