calculate-time
v1.0.11
Published
Calculate time
Downloads
6
Maintainers
Readme
Calculation of time between dates
Description
Calculation of time between dates
Installation
npm i calculate-time
Usage
// Usage example:
import calculateTime from 'calculate-time';
const birthDate = '1990-01-15'; // Birthdate
const toDate = '2023-09-18'; // Date to compare
const language = {
year: 'year',
month: 'month',
day: 'day',
};
const result = calculateTime(birthDate, toDate, language);
console.log(result); // Example output: "33 years 8 months 3 days"
import calculateTime from 'calculate-time';
const experienceTime_1 = '2010-01-01'; // Date of the first experience
const experienceTime_2 = '2015-01-01'; // Date of the second experience
const experience = calculateTime(experienceTime_1, experienceTime_2); // Example output: "4 years 0 months 0 days"
console.log(experience);
Parameters
| Parameter | Type | Description | | --------- | ------ | ---------------------------------------------------------------------------------------------- | | birthDate | string | Date of birth | | to | string | Date to compare | | language | object | Object with the names of the time units. Example: { year: 'year', month: 'month', day: 'day' } |