1kb Relative Datetime Formatting Library – timeago.js

Category: Date & Time | September 8, 2021
Author:Titanium2099
Views Total:92 views
Official Page:Go to website
Last Update:September 8, 2021
License:MIT

Preview:

1kb Relative Datetime Formatting Library – timeago.js

Description:

A super tiny (less than 1kb) time ago (also called relative time) JavaScript library.

It automatically converts timestamps to a human-readable format with live update, such as “right now”, “3 Days ago”, etc.

See Also:

How to use it:

1. Import the timeago.js library.

<script src="timeago.js"></script>

2. Create a new instance of the timeago.js.

const instance = new timeago();

3. Convert a datetime string into a human-readable format.

instance.timeago(Date.now())
=> Right Now
instance.timeago(Date.parse('01 Jan 1970 00:00:00 GMT'))
=> about 51 years ago

You Might Be Interested In:


Leave a Reply