Learn Lua · Time, IDs and checks · Lesson 1 of 4
Dates and times
time.parse reads a date and time written like "2026-03-30T09:15:00Z": the date, a T,
the time, and Z for UTC. Add a period to get a new time, and format it however you need:
local ordered = time.parse("2026-03-30T09:15:00Z")
ordered:add(time.days(3)):format("%Y-%m-%d") --> "2026-04-02"
ordered:month() --> 3later:diff(earlier) gives the time from the earlier moment to the later one. Write the
later time first, or the result is negative. :millis() turns it into milliseconds, and
dividing by 3,600,000 gives hours, which can include a fraction:
local arrived = time.parse("2026-03-31T15:30:00Z")
local start = time.parse("2026-03-30T09:00:00Z")
arrived:diff(start):millis() / 3600000 --> 30.5What your code receives
Your code gets its data as input. The type Input line at the top of the code lists every field, and the editor uses it to suggest field names and spot typos. Here is an example. Each check sends different values, so work from the fields rather than these exact values.
input = { ordered = "2026-03-30T09:00:00Z", shipped = "2026-03-31T15:30:00Z" }Steps
- Return
due: the date three days afterinput.ordered, as"YYYY-MM-DD". - Add
hours: the hours frominput.orderedtoinput.shipped, such as30.5. - Add
month: the month number ofinput.ordered.
Show a hint
Parse both times into locals first. The order was placed before it shipped, so
shipped is the later time.