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

utilsfordate

v2.0.0

Published

Comprehensive date utility library — formatting, parsing, manipulation, diff, timezones and more

Readme

utilsfordate

A comprehensive, zero-dependency TypeScript date utility library.

Installation

npm install utilsfordate

Usage

import { format, toISODate, addDays, fromNow, isToday } from 'utilsfordate';

format(new Date(), 'DDDD, MMMM Do YYYY');  // "Saturday, February 28th 2026"
toISODate(new Date());                      // "2026-02-28"
addDays(new Date(), 7);                     // Date 7 days from now
fromNow('2026-01-01');                      // "2 months ago"
isToday(new Date());                        // true

API

Formatting

| Function | Example Output | |---|---| | format(date, pattern) | Custom token-based format | | toISODate(date) | 2026-02-28 | | toISODateTime(date) | 2026-02-28T14:30:00 | | toISOFull(date) | 2026-02-28T14:30:00+05:30 | | toUSShort(date) | 02/28/2026 | | toEUShort(date) | 28/02/2026 | | toUSLong(date) | February 28, 2026 | | toEULong(date) | 28 February 2026 | | toShortMonth(date) | Feb 28, 2026 | | toFullWithWeekday(date) | Saturday, February 28, 2026 | | toRFC2822(date) | Sat, 28 Feb 2026 14:30:00 +0000 | | toTime12h(date) | 2:30 PM | | toTimeLong(date) | 14:30:00 | | toTimeWithMs(date) | 14:30:00.123 | | toUnixTimestamp(date) | 1740744600 | | toQuarter(date) | Q1 2026 | | toISOWeek(date) | 2026-W09 | | toLocaleString(date, locale) | Intl-based locale format |

Format Tokens

| Token | Output | |---|---| | YYYY / YY | 2026 / 26 | | MMMM / MMM / MM / M | February / Feb / 02 / 2 | | DDDD / DDD | Saturday / Sat | | DD / D / Do | 28 / 28 / 28th | | HH / H / hh / h | 24h / 12h variants | | mm / ss / SSS | Minutes / Seconds / Milliseconds | | A / a | AM / am | | Z / ZZ | +05:30 / +0530 | | X / x | Unix seconds / ms | | Q / W | Quarter / ISO Week | | [text] | Literal escape |

Manipulation

addDays(date, 5)       subtractDays(date, 5)
addMonths(date, 2)     subtractMonths(date, 2)
addYears(date, 1)      subtractYears(date, 1)
addHours(date, 3)      addMinutes(date, 30)
addWeeks(date, 2)      addSeconds(date, 60)

Start / End of Period

startOfDay(date)    endOfDay(date)
startOfWeek(date)   endOfWeek(date)
startOfMonth(date)  endOfMonth(date)
startOfQuarter(date) endOfQuarter(date)
startOfYear(date)   endOfYear(date)
startOfHour(date)   endOfHour(date)

Predicates

isToday(date)      isYesterday(date)   isTomorrow(date)
isPast(date)       isFuture(date)
isWeekend(date)    isWeekday(date)
isLeapYear(date)   isValidDate(date)
isBefore(a, b)     isAfter(a, b)
isSameDay(a, b)    isSameMonth(a, b)   isSameYear(a, b)
isBetween(date, start, end)

Diff

diff(a, b)           // => { years, months, weeks, days, hours, minutes, seconds, ms }
diffInDays(a, b)
diffInMonths(a, b)
diffInYears(a, b)
durationBetween(a, b) // => "3 days, 2 hours"
fromNow(date)         // => "2 months ago" / "in 3 days"

Parsing

parseDDMMYYYY('28/02/2026')
parseMMDDYYYY('02/28/2026')
parseYYYYMMDD('2026-02-28')
parseAny('Feb 28 2026')

Getters

getAge(date)
getQuarter(date)
getWeekNumber(date)
getDayOfYear(date)
getDaysInMonth(date)
getDaysInYear(date)

Timezone

toTimezone(date, 'Asia/Kolkata')
getTimezoneOffset('America/New_York')

Convenience

now()        // current Date
today()      // start of today
tomorrow()   // start of tomorrow
yesterday()  // start of yesterday
min(d1, d2, d3)
max(d1, d2, d3)
clamp(date, min, max)
roundToNearestMinutes(date, 15)

License

ISC