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

dater-lib

v1.0.0

Published

small and handy library for working with dates. It provides functions for formatting, getting the current date, and calculating the difference between dates.

Readme

dater-lib

dater-lib is tiny lightweight library for working with dates, providing functions for formatting, getting the current date, and calculating the difference between dates.

Installation

Install the library via npm:

npm install dater-lib

Usage

Import the functions from the library and use them in your project:

const { formatDate, now, formattedNow, daysBetween, getDayOfWeekName } = require('dater-lib');

// Example usage
const currentDate = new Date();
console.log(formatDate(currentDate, "yyyy-MM-dd hh:mm:ss")); // "2024-12-23 15:30:45"
console.log(now()); // Current time in milliseconds
console.log(formattedNow()); // Current date in "yyyy-MM-dd hh:mm:ss" format
console.log(daysBetween(new Date("2024-01-01"), new Date("2023-01-01"))); // Difference in days
console.log(getDayOfWeekName(currentDate)); // "Monday"

API

formatDate(date, formatString="yyyy-MM-dd hh:mm:ss")

Formats a date according to the specified template.

  • Parameters:
    • date (Date): The date to format.
    • formatString (string): The formatting template. Supported placeholders:
      • yyyy — year
      • MM — month
      • dd — day of the month
      • ddd — day of the week name
      • hh — hours
      • mm — minutes
      • ss — seconds
  • Returns: A string with the formatted date.

now()

Returns the current time in milliseconds since January 1, 1970.

  • Returns: A number.

formattedNow()

Returns the current date formatted as yyyy-MM-dd hh:mm:ss.

  • Returns: A string.

daysBetween(date1, date2)

Calculates the difference in days between two dates.

  • Parameters:
    • date1 (Date): The first date.
    • date2 (Date): The second date.
  • Returns: The difference in days (number). If the second date is later than the first, the result will be negative.

getDayOfWeekName(date)

Returns the name of the day of the week for a given date.

  • Parameters:
    • date (Date): The date for which to get the day of the week name.
  • Returns: A string with the name of the day of the week (e.g., "Monday").

Example

const { formatDate, formattedNow, daysBetween, getDayOfWeekName } = require('dater-lib');

console.log(formattedNow()); // "2024-12-23 15:30:45"
console.log(daysBetween(new Date("2024-01-01"), new Date("2023-01-01"))); // 365
console.log(getDayOfWeekName(new Date())); // "Monday"

License

MIT