@lbanc/date-time-utils
v1.0.0
Published
A lightweight utility package for formatting, adding days, and calculating differences between dates, designed to simplify date manipulations in JavaScript projects.
Downloads
4
Readme
Date and Time Utility Package
A lightweight utility package for working with dates and times.
Installation
npm install date-time-utils
Functions
Formats a given date into a string. The default format is YYYY-MM-DD.
const { formatDate } = require('date-time-utils');
console.log(formatDate('2024-10-01')); // "2024-10-01"
Adds a given number of days to a date.
const { addDays } = require('date-time-utils');
console.log(addDays('2024-10-01', 5)); // "2024-10-06"
Returns the difference in days between two dates.
const { differenceInDays } = require('date-time-utils');
console.log(differenceInDays('2024-10-01', '2024-10-10')); // 9
Step 8: Publish to NPM
Login to NPM (if you haven’t already):
npm login
Publish your package:
npm publish