Skip to content

Built in codes

Farhan Reza edited this page Feb 21, 2024 · 3 revisions

Welcome to the diff-ymd-package wiki👋

Welcome to the Built in codes page of diff-ymd-package!

formattedYMD()

// format output in aY bM cD format
const result = Formatter.formattedYMD(); // Output: "1Y 11M 30D"(depends on your inputs)

customizeFormat(yearUnit, monthUnit, dayUnit, partSeparator)

// create format of your choice
const customizedFormat = Formatter.customizeFormat('Y', 'Ms', 'Ds', '-'); // Output: "1Y-11Ms-30Ds"(depends on your inputs)

diffArray()

// return an array having years, months, days, and the formatted difference
const resultArray = Formatter.diffArray(); // Output: [1, 11, 30, '1Y 11M 30D'](depends on your inputs)

diffInMonths()

// Calculate the difference in months
const monthsDifference = Formatter.diffInMonths(); // Output: 23(depends on your inputs)

diffInWeeks()

// Calculate the difference in weeks
const weeksDifference = Formatter.diffInWeeks(); // Output: 104(depends on your inputs)

diffInDays()

// Calculate the difference in days
const daysDifference = Formatter.diffInDays(); // Output: 729(depends on your inputs)

diffInYears()

// Calculate the difference in years
const yearsDifference = Formatter.diffInYears(); // Output: 1(depends on your inputs)

diffInHours()

// Calculate the difference in hours
const hoursDifference = Formatter.diffInHours(); // Output: 17496(depends on your inputs)

diffInMinutes()

// Calculate the difference in minutes
const minutesDifference = Formatter.diffInMinutes(); // Output: 1049760(depends on your inputs)

diffInSeconds()

// Calculate the difference in seconds
const secondsDifference = Formatter.diffInSeconds(); // Output: 62985600(depends on your inputs)

For more information, support or help, contact us:

Farhan Reza's GitHub Farhan Reza's LinkedIn