diff as Global Date Object method
diffDates(date) → {DatesYMD}
Creates an instance of DatesYMD.
Parameters:
Name | Type | Description |
---|---|---|
date |
string | (type- String but Number for epoch, and Object for dateObject) - The date to be differed, in the format 'yyyy-mm-dd' or 'yyyy/mm/dd' or yyyy.mm.dd or dateString or dateObject or Timestamp(epoch). |
Returns:
An object containing methods for date difference calculations.
- Type
- DatesYMD
Global DatesYMD methods
diffDates(firstDate, secondDate) → {DatesYMD}
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:
Returns:
An object containing methods for date difference calculations.
- Type
- DatesYMD
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 years, months, days, and a formatted 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
Type Definitions
DatesYMD
Represents a utility for calculating the difference between two
dates in formatted or desired customized ways.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
diffArray |
function | Calculates the difference between two dates and returns an array containing years, months, days, and a formatted difference string. |
formattedYMD |
function | Returns the formatted difference between two dates. |
customizeFormat |
function | Customizes the difference using specified units and separators. |
diffInMonths |
function | Calculates the difference in months between two dates. |
diffInWeeks |
function | Calculates the difference in weeks between two dates. |
diffInDays |
function | Calculates the difference in days between two dates. |
diffInYears |
function | Calculates the difference in years between two dates. |
diffInHours |
function | Calculates the difference in hours between two dates. |
diffInMinutes |
function | Calculates the difference in minutes between two dates. |
diffInSeconds |
function | Calculates the difference in seconds between two dates. |
- Source: