mikaelvesavuori/chrono-utils

View on GitHub
src/getDiffInSeconds.ts

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * @description Get the difference in seconds between two moments in time (i.e. Unix timestamps).
 *
 * @example getDiffInSeconds('1670873500000', '1670873600000');
 *
 * @returns `100`
 */
export const getDiffInSeconds = (earlierTime: string, laterTime: string): number =>
  Math.floor((parseInt(laterTime) - parseInt(earlierTime)) / 1000);