Skip to main content
str.format_time(time_value, format, timezone) returns a time as a string. Two things differ from what you may expect: the time is in seconds, while time, time_close and timenow are in milliseconds, and the format is a layout, not a list of letter codes.

Seconds, not milliseconds

Divide a Lipi time by 1000 and round down: math.floor(time / 1000). Passing time itself compiles, because it is an integer, but the result is a date tens of thousands of years from now: the function reads the number as seconds.
That script compiles and shows the wrong year. Nothing in the compiler flags it.

The layout

Write the layout as the date 2006-01-02 15:04:05 (a Monday, January 2, 2006, 3:04:05 PM) would appear in the format you want. The parts of that reference date are the codes: So "2006-01-02 15:04" gives 2026-10-25 14:30, "02 Jan 15:04" gives 25 Oct 14:30 and "Mon 03:04 PM" gives Sun 02:30 PM.

The time zone

The third argument is optional and defaults to "UTC". Give it as "UTC+3", "UTC-5" or "GMT+0530" (hours, or hours and minutes), or as an IANA name such as "America/New_York". syminfo.timezone is the instrument’s own zone. An unknown zone makes the result na, not an error.

The mistake to avoid

Passing the milliseconds of time straight in, as above. Divide by 1000 first. See Sessions and intervals and Text and markers.