New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

little-timestamp

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

little-timestamp

A small & opinionated timestamp formatting library

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source
banner
NPM Version Build Status

A small & opinionated timestamp formatting library
Built by Matt Simpson | Inspired by Steven Tey & Timo Lins

Usage

import { formatTimestamp } from "little-timestamp";

const today = new Date("2025-06-02T12:00:00.000Z"); // For testing purposes
const timestamp = new Date("2025-06-02T06:00:00.000Z"); // 6am

console.log(formatTimestamp(timestamp, { today })); // Outputs: "6h ago"

Installation

With Bun

bun add little-timestamp

With NPM

npm i little-timestamp

Formatting Examples

DescriptionOutput
Past
<1sJust now
1-59s"N"s ago
1-59m"N"m ago
1-23h"N"h ago
>24hJun 1
>24h different yearJun 1, 2024
Future
1-59s"N"s from now
1-59m"N"m from now
1-23h"N"h from now
>24hJun 1
>24h different yearJun 1, 2026

Advanced Options

Most of the formatting behavior is opinionated and can't be changed. However, there are some options that can be used to customize the output.

import { formatTimestamp } from "little-timestamp";

// ...

formatTimestamp(timestamp, {
  locale: "es-ES", // Overwrite the default date locale
  today: new Date(), // Overwrite the default "today" date, useful for testing purposes
});

Contribute

We welcome contributions! If you'd like to improve little-timestamp or have any feedback, feel free to open an issue or submit a pull request.

License

MIT

Keywords

timestamp

FAQs

Package last updated on 02 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts