API Reference › DateTime › DateTime.format
method

DateTime.format

DateTime.format(dt, pattern) -> string

Renders the instant dt as a string, filling the tokens in pattern with zero-padded fields and copying every other character through verbatim. The pattern must be a string literal — it is expanded at compile time, so there is no runtime pattern scanner. Recognised tokens: YYYY (4-digit year), YY (2-digit year), MM (month), DD (day), HH (hour, 24h), mm (minute), ss (second).

Example

program Demo {
  handler Step phase Update {
    let t = DateTime.from(2026, 8, 30, 7, 5, 9)
    let stamp = DateTime.format(t, "YYYY-MM-DD HH:mm:ss")   # "2026-08-30 07:05:09"
  }
}
← All symbols