---
id: datetime-format
name: DateTime.format
category: datetime
kind: namespace-method
tokens: DateTime.format
sig: DateTime.format(dt, pattern) -> string
tip: Render an instant as text using a token pattern.
order: 10
ns: DateTime
member: format
---
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).
```ludic
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"
}
}
```