-
-
Notifications
You must be signed in to change notification settings - Fork 11
Built in codes
Farhan Reza edited this page Feb 21, 2024
·
3 revisions
Welcome to the diff-ymd-package wiki👋
// format output in aY bM cD format
const result = Formatter.formattedYMD(); // Output: "1Y 11M 30D"(depends on your inputs)
// create format of your choice
const customizedFormat = Formatter.customizeFormat('Y', 'Ms', 'Ds', '-'); // Output: "1Y-11Ms-30Ds"(depends on your inputs)
// 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)
// Calculate the difference in months
const monthsDifference = Formatter.diffInMonths(); // Output: 23(depends on your inputs)
// Calculate the difference in weeks
const weeksDifference = Formatter.diffInWeeks(); // Output: 104(depends on your inputs)
// Calculate the difference in days
const daysDifference = Formatter.diffInDays(); // Output: 729(depends on your inputs)
// Calculate the difference in years
const yearsDifference = Formatter.diffInYears(); // Output: 1(depends on your inputs)
// Calculate the difference in hours
const hoursDifference = Formatter.diffInHours(); // Output: 17496(depends on your inputs)
// Calculate the difference in minutes
const minutesDifference = Formatter.diffInMinutes(); // Output: 1049760(depends on your inputs)
// Calculate the difference in seconds
const secondsDifference = Formatter.diffInSeconds(); // Output: 62985600(depends on your inputs)