Skip to content
Algo Trade Analytics Docs

str.format_time() - Pine Script Function

Converts the time timestamp into a string formatted according to format and timezone.

str.format_time(time, format, timezone) → series string
NameTypeDescription
timeseries intUNIX time
inmilliseconds.

The formatted string.

  • The M, d, h, H, m and s tokens can all be doubled to generate leading zeros. For example, the month of January will display as 1 with M, or 01 with MM.
//@version=6
indicator("str.format_time")
if timeframe.change("1D") formattedTime =
str.format_time(time, "yyyy-MM-dd HH:mm", syminfo.timezone)
label.new(bar_index, high, formattedTime)