Skip to main content

DateTime():isBetween()

Checks if the current DateTime object is between two other DateTime objects (inclusive).

Signature

isBetween(start: DateTime, end: DateTime): boolean

Parameters

ParameterTypeDescription
startDateTimeThe start DateTime object.
endDateTimeThe end DateTime object.

Returns

  • Type: boolean
  • true if the current DateTime is between start and end (inclusive), false otherwise.

Examples

local date = DateTime(2024, 1, 15)
local start = DateTime(2024, 1, 10)
local end_date = DateTime(2024, 1, 20)

local result1 = date:isBetween(start, end_date) -- result will be true
toast(tostring(result1))

local dateOutside = DateTime(2024, 1, 25)
local result2 = dateOutside:isBetween(start, end_date) -- result will be false
toast(tostring(result2))