magnifique-date-util
v1.0.2
Published
```bash npm install magnifique-date-util ``` ### Usage ```bash const { formatDate, dateDiffInDays, parseDate } = require('magnifique-date-utils');
Downloads
2
Readme
MAGNIFIQUE DATE UTIL
Installation
npm install magnifique-date-util
Usage
const { formatDate, dateDiffInDays, parseDate } = require('magnifique-date-utils');
console.log(formatDate(new Date(), 'YYYY-MM-DD')); // Output: Current date formatted as 'YYYY-MM-DD'
console.log(dateDiffInDays('2024-03-01', '2024-03-06')); // Output: 5 (difference between the two dates in days)
console.log(parseDate('2024-03-06')); // Output: Date object representing March 6, 2024
formatDate(date, format)
Formats a date object according to the specified format string.
.date
: The date object to format.
.format
: The format string. Defaults to 'YYYY-MM-DD'. Available placeholders: YYYY, MM, DD.
dateDiffInDays(date1, date2)
Calculates the difference in days between two dates.
.date1
: The first date (in string format).
.date2
: The second date (in string format).
.parseDate(dateString)
Parses a date string and returns a Date object.
.dateString
: The date string to parse.