Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Micro npm Packages
  3. twas

twas

MITJavaScript

A 280-byte JavaScript function that converts timestamps to human-readable relative time strings like '3 seconds ago'.

GitHubGitHub
251 stars10 forks0 contributors

What is twas?

twas is a tiny JavaScript function that converts timestamps into human-readable relative time strings, such as '3 seconds ago' or '2 days ago'. It solves the problem of formatting time differences in a lightweight, dependency-free way for web and Node.js applications.

Target Audience

JavaScript developers building applications that need to display relative timestamps without adding significant bundle size, such as in chat apps, social feeds, or activity logs.

Value Proposition

Developers choose twas for its extreme minimalism (280 bytes) and simplicity, offering a focused solution for relative time formatting without the overhead of larger date libraries.

Overview

🕰 Tiny (280B) relative time string function (eg: "3 seconds ago")

Use Cases

Best For

  • Adding relative timestamps to social media or chat applications
  • Displaying activity logs with human-readable time differences
  • Reducing bundle size in performance-sensitive frontend projects
  • Formatting dates in lightweight Node.js utilities or CLI tools
  • Replacing heavier date libraries for basic relative time needs
  • Prototyping or small projects where minimal dependencies are preferred

Not Ideal For

  • Applications requiring multi-language relative time strings (i18n)
  • Projects that need to format future dates or handle time zone conversions
  • Systems where custom time intervals or advanced date formatting is necessary
  • Large-scale applications needing comprehensive date manipulation libraries

Pros & Cons

Pros

Ultra-Lightweight Bundle

At 280 bytes minified and gzipped, it adds negligible overhead to web applications, as emphasized in the GitHub description.

Simple API Design

The function takes a timestamp and returns a readable string like '5 seconds ago', making it straightforward to integrate without configuration hassles.

Zero Dependencies

Being self-contained, it avoids dependency bloat and reduces maintenance risks in projects, as noted in the key features.

Focused on Readability

Outputs human-friendly phrases such as 'just now' or '2 weeks ago', enhancing user experience in time-sensitive displays like chat apps or feeds.

Cons

No Internationalization Support

Only provides English output, which limits its use in global applications without additional localization efforts, a common need not addressed.

Limited to Past Timestamps

Primarily handles past dates; support for future dates or complex time ranges is not built-in, as seen from the usage example focusing on 'ago'.

Minimal Customization Options

Offers no configuration for adjusting time thresholds or output formats, restricting flexibility for specific project requirements.

Frequently Asked Questions

Quick Stats

Stars251
Forks10
Contributors0
Open Issues0
Last commit3 years ago
CreatedSince 2018

Tags

#date-time#timeago#time#lightweight#relative-time#frontend#nodejs#utility-library#time-formatting#javascript

Built With

J
JavaScript

Included in

Micro npm Packages4.6k
Auto-fetched 10 hours ago

Related Projects

timeago.jstimeago.js

:clock8: :hourglass: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.

Stars5,370
Forks404
Last commit2 months ago
fechafecha

Lightweight and simple JS date formatting and parsing

Stars2,067
Forks123
Last commit3 years ago
pretty-mspretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`

Stars1,216
Forks69
Last commit11 days ago
time-stamptime-stamp

Get a formatted timestamp. Used in gulp, assemble, generate, and many others.

Stars109
Forks17
Last commit5 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub