Sidechair

input.time()

Browse the reference

Adds a date and time setting to the script and returns it as a timestamp in milliseconds since 1970.

Try it in the editor

input.time returns a Unix timestamp in milliseconds, starting at defval. Write the default with the timestamp function, for example timestamp("2024-01-15T09:30:00").

Compare it with the time variable to start or stop a calculation at a chosen date: time >= startTime.

Syntax

Pine Script
input.time(defval: const int, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input int

Arguments

NameTypeDefaultDescription
defvalconst intrequiredDefault timestamp in milliseconds, usually made with the timestamp function.
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
tooltipconst stringnaText shown in a tooltip beside the input in the Settings dialog.
inlineconst stringnaEntries sharing the same inline text sit on one row of the Settings dialog.
groupconst stringnaHeading the input is listed under in the Settings dialog.
confirmconst boolfalseWhen true, the script asks for this value when it is first added to the chart.
displayconst plot_displaydisplay.allWhere the value appears: a display.* constant or a combination of them.
activeinput booltrueWhen false, the input is greyed out and cannot be edited.

Returns

input int: the chosen timestamp, in milliseconds.

Remarks

  • On Sidechair: the setting is a number box holding the millisecond value, not a calendar picker.
  • On Sidechair: confirm, display and active are accepted and ignored.

Example

Pine ScriptStart shading from a dateOpen in editor
//@version=6
indicator("From date", overlay = true)
start = input.time(timestamp("2024-01-02T00:00:00"), "Start")
bgcolor(time >= start ? color.new(color.green, 92) : na)

See also

Runs on Sidechair