Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

timestamp() - Pine Script Function

timestamp() lets you generate UNIX timestamps from date components or ISO / RFC-formatted strings. Pine relies on these values for scheduling, session comparisons, and date arithmetic.

timestamp(dateString) → const int
timestamp(timezone, year, month, day, hour, minute, second) → series int
timestamp(year, month, day, hour, minute, second) → series int

There are additional overloads for const vs series arguments; Pine infers the correct one based on input types.

NameTypeDescription
dateStringconst/series stringDate/time string in RFC 2822 ("20 Feb 2024 09:30:00 -0500") or ISO 8601 ("2024-02-20T09:30:00-05:00") format.
timezoneconst/series string (optional)Timezone identifier or offset (e.g., "America/New_York", "GMT+3").
year, month, day, hour, minute, secondconst/series intComponents of the date/time. Omitted components default to zero.

series int — UNIX timestamp in milliseconds for the specified date/time.

  • When no timezone is provided, timestamp() assumes UTC (GMT+0). This differs from time(), which operates in the exchange timezone by default.
  • Use timestamp() with time >= timestamp(...) style checks to enable logic at specific calendar moments (e.g., new year, scheduled release).
  • timestamp() with literal inputs yields const int outputs, useful for static configuration (e.g., indicator titles).
//@version=6
indicator("Scheduled alert window", overlay=true)
releaseTime = input.string("2024-09-20T08:30:00-04:00", "Event time")
eventTs = timestamp(releaseTime)
isEventBar = time >= eventTs and time[1] < eventTs
plotshape(isEventBar, style=shape.labelup, text="Event",
color=color.new(color.orange, 0), textcolor=color.white,
location=location.abovebar)