DateTime():startOf()
Définit l'objet DateTime au début d'une unité de temps spécifiée (par ex., début du jour, début du mois).
Signature
startOf(unit: string): DateTime
Paramètres
| Paramètre | Type | Description |
|---|---|---|
unit | string | L'unité de temps dont il faut définir le début. Les unités prises en charge incluent :year, month, week, day, hour, minute, second |
Renvoie
- Type :
DateTime - L'instance
DateTimeactuelle, permettant le chaînage des méthodes.
Exemples
local now = DateTime()
-- Set to the start of the current day
now:startOf("day")
toast("Start of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the start of the current month
now = DateTime() -- Reset
now:startOf("month")
toast("Start of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the start of the current year
now = DateTime() -- Reset
now:startOf("year")
toast("Start of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))