Skip to main content

Time & Date Utilities

TinyPanda provides built-in functions to easily work with dates, manipulate time intervals, or handle sleep. All internal timestamps are stored as milliseconds.

Timestamp & Sleep

now

Returns the current Unix timestamp in milliseconds.

syntax: now();

bamboo start = now(); // e.g., 1783957595

sleep

Pauses the execution of the program for a specific timeframe.

syntax: sleep(durationString);

sleep("2s"); // Pauses for 2 seconds
sleep("100ms"); // Pauses for 100 milliseconds
sleep("500"); // Pauses for 500 milliseconds (fallback)

Time Helpers

These functions calculate the exact decimal duration elapsed between a start and an end millisecond timestamp.

Syntax: FunctionName(StartTimestamp, EndTimestamp)

FunctionArgumentsReturn TypeDescription
getMs(start, end)(Integer, Integer)IntegerReturns total elapsed milliseconds.
getSec(start, end)(Integer, Integer)FloatReturns elapsed time in seconds with decimal precision.
getMin(start, end)(Integer, Integer)FloatReturns elapsed time in minutes.
getHr(start, end)(Integer, Integer)FloatReturns elapsed time in hours.

Date Helpers

These functions extract clear calendar components from a single millisecond Unix timestamp.

Syntax: FunctionName(Timestamp)

FunctionArgumentsReturn TypeDescription / Example
getYear(ts)(Integer)IntegerReturns the 4-digit calendar year (e.g., 2026).
getMonth(ts)(Integer)IntegerReturns the calendar month from 1 to 12 (e.g., 7 for July).
getDate(ts)(Integer)IntegerReturns the day of the month from 1 to 31 (e.g., 13).
getDay(ts)(Integer)StringReturns the day of the week (Sunday, Monday, ..., Saturday).