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

// Returns true
$A.localizationService.isBetween("2017-03-07","March 7, 2017", "12/1/2017");
// Returns false
$A.localizationService.isBetween("2017-03-07 12:00", "March 7, 2017 15:00", "12/1/2017");
// Returns true because the unit is "day"
$A.localizationService.isBetween("2017-03-07 12:00", "March 7, 2017 15:00", "12/1/2017", "day");