Saltar al contenido principal

DateTime():endOf()

Establece el objeto DateTime al final de una unidad de tiempo especificada (p. ej., final del día, final del mes).

Firma

endOf(unit: string): DateTime

Parámetros

ParámetroTipoDescripción
unitStringLa unidad de tiempo cuyo final se desea establecer. Las unidades admitidas incluyen:year, month, week, day, hour, minute, second

Devuelve

  • Tipo: DateTime
  • La instancia actual de DateTime, lo que permite el encadenamiento de métodos.

Ejemplos

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"))