Constructor
new DatesYMD(firstDate, secondDate)
Creates an instance of DatesYMD.
Parameters:
| Name | Type | Description |
|---|---|---|
firstDate |
string | (type- String but Number for epoch, and Object for dateObject) - The first date in the format 'yyyy-mm-dd' or 'yyyy/mm/dd' or yyyy.mm.dd or dateString or dateObject or Timestamp(epoch). |
secondDate |
string | (type- String but Number for epoch, and Object for dateObject) - The second date in the format 'yyyy-mm-dd' or 'yyyy/mm/dd' or yyyy.mm.dd or dateString or dateObject or Timestamp(epoch). |
- Source:
Methods
customizeFormat(yearUnit, monthUnit, dayUnit, partSeparator) → {string}
Customizes the difference using specified units and separators like (a + yearUnit + partSeparator + b + monthUnit + partSeparator + c + dayUnit), eg. aYs-bMs-cDs etc.
Parameters:
| Name | Type | Description |
|---|---|---|
yearUnit |
string | The unit for years. |
monthUnit |
string | The unit for months. |
dayUnit |
string | The unit for days. |
partSeparator |
string | The separator between year, month, and day parts. |
- Source:
Returns:
The customized formatted difference.
- Type
- string
diffArray() → {Array}
Calculates the difference between two dates and returns an array containing Y, M, D, and a formatted 'aY bM cD' difference string.
- Source:
Returns:
An array containing the calculated years, months, days, and the formatted difference.
- Type
- Array
diffInDays() → {number}
Calculates the difference in days between two dates.
- Source:
Returns:
The difference in days.
- Type
- number
diffInHours() → {number}
Calculates the difference in hours between two dates.
- Source:
Returns:
The difference in hours.
- Type
- number
diffInMinutes() → {number}
Calculates the difference in minutes between two dates.
- Source:
Returns:
The difference in minutes.
- Type
- number
diffInMonths() → {number}
Calculates the difference in months between two dates.
- Source:
Returns:
The difference in months.
- Type
- number
diffInSeconds() → {number}
Calculates the difference in seconds between two dates.
- Source:
Returns:
The difference in seconds.
- Type
- number
diffInWeeks() → {number}
Calculates the difference in weeks between two dates.
- Source:
Returns:
The difference in weeks.
- Type
- number
diffInYears() → {number}
Calculates the difference in years between two dates.
- Source:
Returns:
The difference in years.
- Type
- number
formattedYMD() → {string}
Returns the formatted difference between two dates.
- Source:
Returns:
The formatted difference in the format 'aY bM cD'.
- Type
- string