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:

LUA
local ordered = time.parse("2026-03-30T09:15:00Z")
ordered:add(time.days(3)):format("%Y-%m-%d")  --> "2026-04-02"
ordered:month()                               --> 3

later: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:

LUA
local arrived = time.parse("2026-03-31T15:30:00Z")
local start = time.parse("2026-03-30T09:00:00Z")
arrived:diff(start):millis() / 3600000  --> 30.5

What 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.

LUA
input = { ordered = "2026-03-30T09:00:00Z", shipped = "2026-03-31T15:30:00Z" }

Steps

  1. Return due: the date three days after input.ordered, as "YYYY-MM-DD".
  2. Add hours: the hours from input.ordered to input.shipped, such as 30.5.
  3. Add month: the month number of input.ordered.
Show a hint

Parse both times into locals first. The order was placed before it shipped, so shipped is the later time.