minute() - Pine Script Function
minute()
Section titled “minute()”Overview
Section titled “Overview”minute() extracts the minute (0–59) from a UNIX timestamp. By default it uses the symbol’s exchange timezone (syminfo.timezone), but you can supply your own offset or IANA timezone string to align with a different market session.
Syntax
Section titled “Syntax”minute(time, timezone) → series intParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
time | series int | UNIX timestamp in milliseconds. Most scripts pass the built-in time series or values returned by request.security(). |
timezone | series string (optional) | Target timezone in "UTC±HH[:MM]" format or an IANA name like "America/New_York". Defaults to syminfo.timezone. |
Returns
Section titled “Returns”series int — Minute component in the requested timezone.
Remarks
Section titled “Remarks”minute()operates on the timestamp at the open of each bar. On markets with overnight sessions, the returned value reflects the session start time.- Combine with
hour()orsecond()for more precise scheduling, or withtime(timeframe.period, session)to test custom sessions. - When
timezoneis supplied, Pine performs the conversion per bar, so the function remains safe to use withrequest.security()results from foreign exchanges.
Example
Section titled “Example”//@version=5indicator("NY opening range highlight", overlay=true)
// Convert the bar timestamp to Eastern Time (falls back to EST/EDT automatically).nyHour = hour(time, "America/New_York")nyMinute = minute(time, "America/New_York")
isOpeningRange = nyHour == 9 and nyMinute < 30bgcolor(isOpeningRange ? color.new(color.orange, 85) : na, title="Highlight the first 30 minutes after the NY open")
plot(close, "Close", color=color.gray)