Skip to content

Instantly share code, notes, and snippets.

View RienNeVaPlus's full-sized avatar
🔌
Plugged in

RienNeVaPlus RienNeVaPlus

🔌
Plugged in
View GitHub Profile
@RienNeVaPlus
RienNeVaPlus / dateDiff.ts
Last active August 23, 2023 00:20
🕤 dateDiff() - returns a detail object about the difference between two dates
/**
* ☃ dateDiff "Snowman Carl" (http://stackoverflow.com/questions/13903897)
* Returns a detail object about the difference between two dates
*
* When providing custom units, provide them in descending order (eg week,day,hour; not hour,day,week)
*
* @param {Date} dateStart - date to compare to
* @param {Date|string} [dateEnd=new Date()] - second date, can be used as unit param instead
* @param {...string} [units=Object.keys(dateDiffDef)] - limits the returned object to provided keys
*/