Files
30-seconds-of-code/snippets/getDifferenceInSeconds.md
2020-12-24 19:42:30 +05:30

327 B

title, tags
title tags
getDifferenceInSeconds dates,beginner

Returns the diffrence in seconds between 2 supplied dates.

const getDifferenceInSeconds = (start, end) =>
  (end.getTime() - start.getTime()) / 1000;
getDifferenceInSeconds(new Date('2020-12-24 00:00:15'), new Date('2020-12-24 00:00:17')); // 2