DateTime():isSameOrBefore()
Kiểm tra xem đối tượng DateTime hiện tại có giống với hoặc nằm trước một đối tượng DateTime khác hay không.
Khai báo
isSameOrBefore(other: DateTime): boolean
Tham số
| Tham số | Kiểu | Mô tả |
|---|---|---|
other | DateTime | Đối tượng DateTime khác để so sánh. |
Trả về
- Kiểu:
boolean truenếuDateTimehiện tại giống với hoặc nằm trướcotherDateTime,falsenếu không.
Ví dụ
local date1 = DateTime(2024, 1, 5)
local date2 = DateTime(2024, 1, 10)
local date3 = DateTime(2024, 1, 5)
local result1 = date1:isSameOrBefore(date2) -- kết quả sẽ là true
toast(tostring(result1))
local result2 = date1:isSameOrBefore(date3) -- kết quả sẽ là true
toast(tostring(result2))
local result3 = date2:isSameOrBefore(date1) -- kết quả sẽ là false
toast(tostring(result3))