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

timexjs

v1.0.0

Published

An utility library for time and date manipulation

Downloads

83

Readme

🕒 TimeX

A lightweight JavaScript utility library for date and time manipulation.

TimeX provides a collection of simple and powerful functions to format dates, get day/month names, calculate age, check weekdays/weekends, handle timezones, and more. Perfect for modern JavaScript projects.


📦 Installation

You can install TimeX using npm or yarn:

Using npm

npm install timex

Using yarn

yarn add timex

⚡ Usage

import TimeX, {
    formatDate,
    getDayName,
    getShortDayName,
    getMonthName,
    getShortMonthName,
    toISO,
    toUTC,
    toUnix,
    isLeapYear,
    getTimeOfDay,
    getAgeFromDateOfBirth,
    isToday,
    isYesterday,
    isTomorrow,
    isWeekend,
    isWeekday,
    isSameDay,
    getTimeZone
} from 'timex';

// Formatting Dates
console.log(formatDate(new Date(), "DD/MM/YYYY")); // "04/12/2025"

// Day and Month Names
console.log(getDayName(new Date()));        // "Thursday"
console.log(getShortDayName(new Date()));   // "Thu"
console.log(getMonthName(new Date()));      // "December"
console.log(getShortMonthName(new Date())); // "Dec"

// Convert Dates
console.log(toISO(new Date()));   // "2025-12-04T12:30:00.000Z"
console.log(toUTC(new Date()));   // { year: 2025, month: 12, day: 4, hour: 12, minute: 30, second: 0, iso: "2025-12-04T12:30:00.000Z" }
console.log(toUnix(new Date()));  // 1730675400

// Leap Year Check
console.log(isLeapYear(2024)); // true
console.log(isLeapYear(1900)); // false
console.log(isLeapYear(2000)); // true

// Time of Day
console.log(getTimeOfDay(new Date())); // "afternoon"

// Age Calculation
console.log(getAgeFromDateOfBirth("1990-05-15")); // 35

// Relative Date Checks
console.log(isToday(new Date()));          // true
console.log(isYesterday("2025-12-03"));    // true
console.log(isTomorrow("2025-12-05"));     // true

// Weekday / Weekend Checks
console.log(isWeekend(new Date())); // false
console.log(isWeekday(new Date())); // true

// Compare Two Dates
console.log(isSameDay("2025-12-04", new Date())); // true

// Get Timezone
console.log(getTimeZone()); // "Asia/Kolkata"

✅ Features

  • Format dates (formatDate)
  • Get day & month names (long and short)
  • ISO, UTC, and Unix timestamp conversion
  • Leap year detection (isLeapYear)
  • Time of day detection (getTimeOfDay)
  • Age calculation (getAgeFromDateOfBirth)
  • Relative date checks (isToday, isYesterday, isTomorrow)
  • Weekday/weekend checks (isWeekday, isWeekend)
  • Compare two dates (isSameDay)
  • Timezone detection (getTimeZone)

🔗 License

MIT License