timeagoify
v1.0.2
Published
A simple JavaScript utility to convert dates into human-friendly 'time ago', 'days ago', or 'years ago' format.
Maintainers
Readme
⏳ Time Ago Formatter
A lightweight and easy-to-use JavaScript utility to format any date into "time ago", "days ago", or "years ago" text — perfect for blogs, comment sections, feeds, or any place you show relative time in a human-friendly way.
📦 Installation
# Using npm
npm install timeagoify
# Using yarn
yarn add timeagoify🚀 Usage
👉 ES Module syntax
import { timeAgo, dayAgo, yearAgo } from "timeagoify";
console.log(timeAgo(new Date(Date.now() - 60000))); // 1 minute ago
console.log(dayAgo(new Date(Date.now() - 5 * 24 * 60 * 60 * 1000))); // 5 days ago
console.log(yearAgo(new Date("2019-01-01"))); // 5 years ago👉 CommonJS syntax
const { timeAgo, dayAgo, yearAgo } = require("timeagoify");
console.log(timeAgo(new Date(Date.now() - 60000))); // 1 minute ago
console.log(dayAgo(new Date(Date.now() - 5 * 24 * 60 * 60 * 1000))); // 5 days ago
console.log(yearAgo(new Date("2019-01-01"))); // 5 years ago📂 Project Structure
timeagoify/
├── index.js
├── package.json
├── README.md
├── .gitignore
└── test.js👤 Author
Razz
React.js & Shopify Developer
📧 [email protected]
⚖️ License
This project is licensed under the MIT License — feel free to use it in your personal or commercial projects.
⭐️ Happy Coding!
If you like this package, star it ⭐ and share it with your dev friends! 🚀✨
