isBetween()

Checks if date is between fromDate and toDate, where the match is inclusive.

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");