DateTime():endOf()
Sets the DateTime object to the end of a specified unit of time (e.g., end of the day, end of the month).
Signature
endOf(unit: string): DateTime
Parameters
Parameter | Type | Description |
---|---|---|
unit | String | The unit of time to set the end of. Supported units include:year , month , week , day , hour , minute , second |
Returns
- Type:
DateTime
- The current
DateTime
instance, allowing for method chaining.
Examples
local now = DateTime()
-- Set to the end of the current day
now:endOf("day")
toast("End of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the end of the current month
now = DateTime() -- Reset
now:endOf("month")
toast("End of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the end of the current year
now = DateTime() -- Reset
now:endOf("year")
toast("End of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))