Skip to content

Instantly share code, notes, and snippets.

View DavidMsnap's full-sized avatar

DavidMsnap

  • snapADDY
  • Würzburg
View GitHub Profile
@DavidMsnap
DavidMsnap / datediff.js
Last active January 14, 2021 11:01 — forked from svetoslavovm/datediff.js
JavaScript: DateDiff & DateMeasure: Calculate days, hours, minutes, seconds between two Dates with es6 classes
class DateMeasure {
constructor(ms) {
const negativeMS = ms < 0;
let d, h, m, s;
// this change is needed for it to work with
// date1 before date2 diffs
if (negativeMS) {
ms *= -1;
}