Lewati ke konten utama

DateTime():isBefore()

Memeriksa apakah objek DateTime saat ini sebelum objek DateTime lainnya.

Tanda Tangan

isBefore(other: DateTime): boolean

Parameter

ParameterTypeDescription
otherDateTimeObjek DateTime lain untuk dibandingkan.

Mengembalikan

  • Tipe: boolean
  • true jika DateTime saat ini benar-benar sebelum other DateTime, false jika tidak.

Contoh

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

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

local result2 = date2:isBefore(date1) -- hasil akan false
toast(tostring(result2))