Skip to content

timenow - PineScript Variable

timenow returns the current wall-clock timestamp in milliseconds since 1970-01-01 UTC. Unlike time, it reflects the actual moment the script executes, not the bar’s open or close.

  • Because timenow changes on every update, using it in realtime calculations may lead to repainting.
  • Useful for countdown timers or gating logic by absolute time (timenow >= targetTs).
  • It always reflects UTC-based milliseconds; convert to human-readable strings with str.format_time.
//@version=5
indicator("Wall-clock timestamp", overlay=false)
target = input.time(timestamp("UTC", 2024, 12, 31, 23, 59), "Deadline (UTC)")
secondsToTarget = (target - timenow) / 1000.0
plot(secondsToTarget, "Seconds until deadline", color=color.purple)
plot(0, color=color.gray)