Skip to content

Instantly share code, notes, and snippets.

View tamirazrab's full-sized avatar

Tamir Azrab tamirazrab

  • JazzCash
  • Pakistan
  • 09:06 (UTC +05:00)
View GitHub Profile
@tamirazrab
tamirazrab / dateDiff.ts
Created October 10, 2021 18:48 — forked from RienNeVaPlus/dateDiff.ts
🕤 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
*/