Skip to content

Instantly share code, notes, and snippets.

View rockwellll's full-sized avatar
🏠
Working from home

Ahmed Khattab rockwellll

🏠
Working from home
View GitHub Profile
@rockwellll
rockwellll / useUpdatableTimestamp.js
Last active September 23, 2022 09:04 — forked from shuber/date_helper.js
fuzzy timestamps, time ago in words
export const useUpdatableTimestamp = (controller) => {
return Object.assign(controller, {
timeAgoInWordsWithParsing(from) {
const date = new Date;
date.setTime(Date.parse(from));
return this.timeAgoInWords(date);
},
timeAgoInWords(from) {
return this.distanceOfTimeInWords(new Date(), from);