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

epochify

v1.0.12

Published

🕒 A modern and lightweight date-time utility library for Node.js and browsers.

Readme


Epochify

npm version npm downloads license


Overview

Epochify is a modern and lightweight date-time utility library for Node.js and browsers. It helps you handle timestamps, format dates, and calculate time differences in a clean and efficient way.


Quick Example

import epochify from "epochify";
console.log(epochify.format(Date.now(), "YYYY-MM-DD HH:mm:ss"));

Features

  • Lightweight (under 20kb)
  • Works in both Node.js and browsers
  • Zero dependencies
  • TypeScript support included
  • Simple and clean API design

Installation

npm install epochify
# or
yarn add epochify

Usage

CommonJS Example

const epochify = require("epochify");

console.log(epochify.getFullDateTime());

ES Module Example

import epochify from "epochify";

console.log(epochify.getFullDateTime());

TypeScript Example

import type { FullDateTime } from "epochify";

const dt: FullDateTime = epochify.getFullDateTime();
console.log(dt);

API Reference

Below are all available methods in Epochify, with explanations and examples.

getRawDateTime()

Returns an object containing the current local date and time values.

epochify.getRawDateTime();
/* {
  date: { day: 4, month: 11, year: 2025 },
  time: { hours: 15, minutes: 16, seconds: 00 }
} */

getFormattedDate()

Returns today's date in DD-MM-YYYY format, with each part separately.

epochify.getFormattedDate();
// { formatted: "04-11-2025", day: "04", month: "11", year: 2025 }

getFormattedTime()

Returns current time in HH:MM:SS format and components.

epochify.getFormattedTime();
// { formatted: "15:16:00", hours: "15", minutes: "16", seconds: "00" }

getReadableDate()

Returns date in a human-readable format.

epochify.getReadableDate(); // "Tue Nov 04 2025"

getISODateTime()

Returns the current date/time in ISO 8601 format.

epochify.getISODateTime();
// "2025-11-04T09:46:00.000Z"

getTimestamp()

Returns current timestamp in milliseconds.

epochify.getTimestamp();
// 1762355760000

getUnixTimestamp()

Returns current Unix timestamp in seconds.

epochify.getUnixTimestamp();
// 1762355760

getFullDateTime()

Returns an object with all major date & time formats.

epochify.getFullDateTime();
/*
{
  date: { formatted: "04-11-2025", day: "04", month: "11", year: 2025 },
  time: { formatted: "15:16:00", hours: "15", minutes: "16", seconds: "00" },
  iso: "2025-11-04T09:46:00.000Z",
  unix: 1762355760,
  timestamp: 1762355760000,
  readable: "Tue Nov 04 2025"
}
*/

format(time, formatStyle)

Formats a timestamp/date to a custom string.

epochify.format(Date.now(), "YYYY-MM-DD weekDay HH:mm:ss");
// "2025-11-04 Tue 15:16:00"
epochify.format("2025-01-01T10:30:00Z", "DD/MM/YYYY HH:mm:ss ap");
// "01/01/2025 10:30:00 AM"

diff(orgDate, comDate, unit)

Finds the difference between two dates in any standard unit.

epochify.diff("2025-11-04", "2025-10-31", "days");
// 4

epochify.diff(1762355760000, 1761923760000, "hours");
// 120

getMonthsCount(orgDate, comDate)

Get absolute month difference between two dates.

epochify.getMonthsCount("2025-09-01", "2024-05-15");
// 16

isLeap(year)

Checks if a year is leap.

epochify.isLeap(2024); // true
epochify.isLeap(2025); // false

TypeScript Types

Main interfaces included for TypeScript users:

interface DateObject {
  date: { day: number; month: number; year: number; };
  time: { hours: number; minutes: number; seconds: number; };
}

interface FormattedDate {
  formatted: string;
  day: string;
  month: string;
  year: number;
}

interface FormattedTime {
  formatted: string;
  hours: string;
  minutes: string;
  seconds: string;
}

interface FullDateTime {
  date: FormattedDate;
  time: FormattedTime;
  iso: string;
  unix: number;
  timestamp: number;
  readable: string;
}

Hidden Power Functions (Most Underrated)

These functions aren’t flashy but make Epochify powerful under the hood:

getRawDateTime()

Returns a structured breakdown of the current date and time.

epochify.getRawDateTime();
// → { date: { day: 4, month: 11, year: 2025 }, time: { hours: 22, minutes: 15, seconds: 30 } }

Perfect for low‑level time processing or custom format logic.

getStartOf(unit)

Quickly fetch the start of the current day, month, or year.

epochify.getStartOf('day');
// → 1730678400000 (midnight timestamp)

Useful for analytics, resets, or daily cron comparisons.

add(timestamp, value, unit)

Add or subtract any time value dynamically.

epochify.add(Date.now(), 7, 'days');
// → adds 7 days to the current time

Perfect for scheduling, reminders, or future date calculations.



Advanced Usage Tips

  • Accepts date inputs as string, number, or JS Date object.
  • Safe for frontend and backend.
  • Use .default for ESM/CJS interop if needed.

Why Use Epochify?

  • No dependencies or bloat
  • Consistent and simple API
  • Replace heavier libraries easily
  • Fast, reliable, and TypeScript ready

License

MIT © 2025 Ayush