str.format_time() - Pine Script Function
str.format_time()
Section titled “str.format_time()”Overview
Section titled “Overview”Converts the time timestamp into a string formatted according to format and timezone.
Syntax
Section titled “Syntax”str.format_time(time, format, timezone) → series stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| time | series int | UNIX time |
| in | — | milliseconds. |
Returns
Section titled “Returns”The formatted string.
Remarks
Section titled “Remarks”- 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.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("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)