
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
date-difference-lib
Advanced tools
This library provides a function to calculate the difference between two dates in years, months, and days.
To use this library in your project, you can install it via npm:
npm install date-difference-lib
JS Project:
const { getDateDifference } = require('date-difference-lib');
console.log(getDateDifference("2023-01-01", "2024-01-01"));
React / Angular / Vue (TypeScript):
import { getDateDifference } from 'date-difference-lib';
const diff = getDateDifference("2023-01-01", "2024-01-01", { asObject: true });
console.log(diff.years); // 1
console.log(getDateDifference('2020-01-01', '2023-10-15')); // Output: "3 years, 9 months, 14 days"
console.log(getDateDifference('2022-05-05', '2023-05-06')); // Output: "1 year, 1 day"
getDateDifference(new Date(2024, 0, 1), new Date(2024, 1, 1));
getDateDifference('2023-01-01', '2024-01-01', { utc: false });
// Returns the difference as object
getDateDifference("2024-01-01T10:00:00Z", "2024-02-01T10:00:00Z", { asObject: true });
getDateDifference(1704067200000, 1706745600000);
// negative difference preserved
getDateDifference('2024-01-01', '2023-01-01', { signed: true });
console.log(getDateDifference('2024-01-01', '2023-01-01', { includeTime: true, includeZeroUnits: true }));
// "1 year, 0 months, 0 days, 0 hours, 0 minutes, 0 seconds"
https://www.npmjs.com/package/date-difference-lib?activeTab=readme
FAQs
The library calculates the difference in years, months, and days
We found that date-difference-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.