Lewati ke konten utama

DateTime():isSameOrBefore()

Memeriksa apakah objek DateTime saat ini sama dengan atau sebelum objek DateTime lainnya.

Tanda Tangan

isSameOrBefore(other: DateTime): boolean

Parameter

ParameterTypeDescription
otherDateTimeObjek DateTime lain untuk dibandingkan.

Mengembalikan

  • Tipe: boolean
  • true jika DateTime saat ini sama dengan atau sebelum other DateTime, false jika tidak.

Contoh

local date1 = DateTime(2024, 1, 5)
local date2 = DateTime(2024, 1, 10)
local date3 = DateTime(2024, 1, 5)

local result1 = date1:isSameOrBefore(date2) -- hasil akan true
toast(tostring(result1))

local result2 = date1:isSameOrBefore(date3) -- hasil akan true
toast(tostring(result2))

local result3 = date2:isSameOrBefore(date1) -- hasil akan false
toast(tostring(result3))