Time
Parse, shift and generate RFC 3339 timestamps.
formatdate
formatdate(format, timestamp) → stringFormat a timestamp using a format string.
Uses HCL’s format spec: YYYY (year), MM (month), DD (day), hh (hour), mm (minute), ss (second).
| Parameter | Type | Description |
|---|---|---|
format | string | |
timestamp | string | RFC3339 timestamp. |
formatdate("YYYY-MM-DD", "2026-04-20T12:30:00Z")→ "2026-04-20"
now
now() → stringReturn the current UTC time as an RFC3339 string.
Evaluated at expression-evaluation time. Two now() calls in the same action body may differ by microseconds.
now()→ "2026-04-20T12:00:00Z"
timeadd
timeadd(timestamp, duration) → stringAdd a Go duration to a timestamp.
| Parameter | Type | Description |
|---|---|---|
timestamp | string | RFC3339 timestamp. |
duration | string | Go duration (e.g. “6h”, “30m”). |
timeadd("2026-01-01T00:00:00Z", "24h")→ "2026-01-02T00:00:00Z"
timerandom
timerandom(start, end) → stringReturn a random timestamp between start and end.
| Parameter | Type | Description |
|---|---|---|
start | string | RFC3339 timestamp (inclusive). |
end | string | RFC3339 timestamp (exclusive). |
timerandom(timesub(now(), "30d"), now())timesequence
timesequence(start, end, min_interval, max_interval...) → list(string)Generate timestamps stepping by random intervals between min and max.
Produces timestamps from start until end is reached. With only min_interval, steps are evenly spaced. With both min and max, each step is randomised within the range. Capped at 100,000 entries.
| Parameter | Type | Description |
|---|---|---|
start | string | RFC3339 timestamp. |
end | string | RFC3339 timestamp. |
min_interval | string | Minimum step duration. |
max_interval... | string | Maximum step duration (optional). |
timesequence(timesub(now(), "30d"), now(), "1d", "5d")timeseries
timeseries(start, end, count) → list(string)Distribute exactly N timestamps evenly between start and end.
First entry is start, last is end, intermediate points are equidistant. Use timesequence for interval-based generation.
| Parameter | Type | Description |
|---|---|---|
start | string | RFC3339 timestamp. |
end | string | RFC3339 timestamp. |
count | number | Number of timestamps to generate. |
timeseries(timesub(now(), "90d"), now(), 10)→ ["2026-01-20T...", ..., "2026-04-20T..."]
timesub
timesub(timestamp, duration) → stringSubtract a duration from a timestamp.
Supports extended durations: d (days = 24h) and w (weeks = 7d) on top of Go’s standard units.
| Parameter | Type | Description |
|---|---|---|
timestamp | string | RFC3339 timestamp. |
duration | string | Duration (e.g. “30d”, “2w”, “6h”). |
timesub("2026-04-20T00:00:00Z", "7d")→ "2026-04-13T00:00:00Z"
timeunix
timeunix(timestamp) → numberConvert a timestamp to Unix epoch seconds.
| Parameter | Type | Description |
|---|---|---|
timestamp | string | RFC3339 timestamp. |
timeunix("2026-01-01T00:00:00Z")→ 1767225600