April 29, 2020
A relative date is something like "23 minutes ago", "1 day ago", or "3 months ago".
My favorite Node.js package for formatting a normal Date
object into a nice string is tiny-relative-date.
First, install the package:
npm install tiny-relative-date
Then, you can use it like this:
const relativeDate = require("tiny-relative-date") // import the package
const date = new Date() // any javascript date object
console.log(relativeDate(date)) // this returns the relative date
Done! Now you've got relative dates in Node.js.
Tufts Meal Plan Wrapped
Mar 2, 2024
Building an e-ink picture frame that displays an iCloud photo album
Jan 9, 2024
2023 in review
Jan 5, 2024
Subscribe to my newsletter for a monthly round-up of new blog posts and projects Iām working on!