Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
isBetween()
Signature
isBetween(string | number | Date date, string | number | Date fromDate, string | number | Date toDate, string unit)
Parameters
- date
- Type: string | number | Date
- A datetime string in ISO8601 format, or a timestamp in milliseconds, or a Date object.
- fromDate
- Type: string | number | Date
- A datetime string in ISO8601 format, or a timestamp in milliseconds, or a Date object.
- toDate
- Type: string | number | Date
- A datetime string in ISO8601 format, or a timestamp in milliseconds, or a Date object.
- unit
- Type: string
- A datetime unit. Options are 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
Returns
- Type: boolean
- Returns true if date is between fromDate and toDate, or false otherwise.
Sample Code
1// Returns true
2$A.localizationService.isBetween("2017-03-07","March 7, 2017", "12/1/2017");
3// Returns false
4$A.localizationService.isBetween("2017-03-07 12:00", "March 7, 2017 15:00", "12/1/2017");
5// Returns true because the unit is "day"
6$A.localizationService.isBetween("2017-03-07 12:00", "March 7, 2017 15:00", "12/1/2017", "day");