Chuyển tới nội dung chính

DateTime():isSameOrAfter()

Kiểm tra xem đối tượng DateTime hiện tại có giống với hoặc nằm sau một đối tượng DateTime khác hay không.

Khai báo

isSameOrAfter(other: DateTime): boolean

Tham số

Tham sốKiểuMô tả
otherDateTimeĐối tượng DateTime khác để so sánh.

Trả về

  • Kiểu: boolean
  • true nếu DateTime hiện tại giống với hoặc nằm sau other DateTime, false nếu không.

Ví dụ

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

local result1 = date1:isSameOrAfter(date2) -- kết quả sẽ là true
toast(tostring(result1))

local result2 = date1:isSameOrAfter(date3) -- kết quả sẽ là true
toast(tostring(result2))

local result3 = date2:isSameOrAfter(date1) -- kết quả sẽ là false
toast(tostring(result3))