メインコンテンツまでスキップ

DateTime():endOf()

DateTime オブジェクトを指定した時間単位の終わり(例:日の終わり、月の終わり)に設定します。

シグネチャ

endOf(unit: string): DateTime

パラメータ

パラメータ説明
unitString終わりを設定する時間単位。対応する単位:year, month, week, day, hour, minute, second

戻り値

  • 型: DateTime
  • 現在の DateTime インスタンス。メソッドチェーンが可能です。

local now = DateTime()
-- 現在の日の終わりに設定
now:endOf("day")
toast("End of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))

-- 現在の月の終わりに設定
now = DateTime() -- リセット
now:endOf("month")
toast("End of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))

-- 現在の年の終わりに設定
now = DateTime() -- リセット
now:endOf("year")
toast("End of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))