Skip to content
lsl.devlsl.devLSL Dev

Time

A script measures and waits for time in a few distinct ways: a repeating timer that raises an event, a sleep that pauses the script, a script clock that counts how long the script has been running, and real-world clocks in UTC and Second Life Time. Regions also have an environmental time of day that follows the day cycle, which is not the same as the clock. Time interacts with the event model: a timer is an event like any other and waits its turn in the queue.

Concepts in time

  • Each script has one timer, which raises the timer event at most once every sec seconds
    • Passing 0.0 stops further timer events
    • Setting a new timer replaces the old one and resets the timer clock, so calling it again more often than sec means the timer never fires
    • The timer survives state changes, but does not survive resets
    • Timer events can arrive late, because of time dilation, the default event delay, a long-running event or llSleep. The timer event is not an interrupt; the current event finishes first
  • A script can sleep for a number of seconds, and does nothing during that time
  • Script time counts how long the script has been running, with subsecond precision
    • It is unaffected by time dilation, but does not count time while the script is suspended, the object is in inventory, or the wearer is offline
    • It restarts when the script is reset, or explicitly, or when read and reset in one call
    • In LSL its accuracy falls as the value grows, so reset it whenever practical
  • Real-world time comes from the system clock
  • Environmental time follows the day cycle of the parcel or the region, with its day length and offset. See Environments for the sky itself
  • Time dilation is how the region copes with lag: it slows script time and execution, from 1.0 (none) down to 0.0, when script execution halts
  • A script can set the minimum delay between events it handles

Timer and clock functions

voidllSetTimerEvent(float sec)
eventtimer()
voidllSleep(float sec)
voidllMinEventDelay(float delay)
floatllGetTime()
voidllResetTime()
floatllGetAndResetTime()
integerllGetUnixTime()
stringllGetTimestamp()
stringllGetDate()
floatllGetWallclock()
floatllGetGMTclock()
floatllGetTimeOfDay()
floatllGetRegionTimeOfDay()
floatllGetRegionTimeDilation()

Dates after 2038

llGetUnixTime returns a signed 32-bit integer, so it cannot represent times after 2038-01-19 03:14:08 UTC. llGetTimestamp will correctly report time through 2038.

Time functions in detail

voidllSetTimerEvent(float sec)
Cause the timer event to be triggered a maximum of once every sec seconds. Passing in 0.0 stops further timer events
eventtimer()
Triggered at the interval set with llSetTimerEvent. Only one timer can be active at one time
voidllSleep(float sec)
Puts the script to sleep for sec seconds. The script will not do anything during this time
voidllMinEventDelay(float delay)
Set the minimum time between events being handled. The minimum delay is maintained between state changes
floatllGetTime()
Returns script time in seconds with subsecond precision since the script started, was last reset, or call to either llResetTime or llGetAndResetTime
voidllResetTime()
Resets the script time to zero
floatllGetAndResetTime()
Returns script time in seconds and then resets the script time to zero
integerllGetUnixTime()
Returns the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC from the system clock
stringllGetTimestamp()
Returns the current date and time in the UTC time zone in the ISO 8601 format "YYYY-MM-DDThh:mm:ss.ff..fZ". Appears to be accurate to milliseconds
stringllGetDate()
Returns the current date in the UTC time zone as "YYYY-MM-DD"
floatllGetWallclock()
Returns the time in seconds since midnight Pacific time (PST/PDT), truncated to whole seconds. That is the same as the time of day in SLT expressed as seconds
floatllGetGMTclock()
Returns the time in seconds since midnight GMT, truncated to whole seconds
floatllGetTimeOfDay()
Returns the seconds since parcel environmental midnight, or region uptime if that is smaller or the parcel’s sun is fixed
floatllGetRegionTimeOfDay()
Returns the seconds since region environmental midnight, or region uptime if that is smaller or the region’s sun is fixed
floatllGetRegionTimeDilation()
Returns the current time dilation, from 0.0 (full dilation) to 1.0 (no dilation). It is used as the ratio between the change of script time to that of real world time

Additional

See also Feature EventsFeature ScriptsFeature EnvironmentsCategory Time

Adapted from the Second Life Wiki pages LlSetTimerEvent (revision 1214214, 2023-07-05), Timer (revision 1194108, 2015-01-22), LlSleep (revision 1217326, 2024-09-22), LlMinEventDelay (revision 1212509, 2022-10-01), LlGetTime (revision 1218600, 2026-01-31), LlGetAndResetTime (revision 1218526, 2025-11-30), LlGetUnixTime (revision 1218796, 2026-04-20), LlGetTimestamp (revision 1217942, 2025-02-01), LlGetWallclock (revision 1214560, 2023-09-06) and LlGetRegionTimeDilation (revision 1218444, 2025-08-30), including the transcluded Template:Issues/SVC-3293 (revision 1155854, 2011-10-17), Template:Issues/BUG-4703 (revision 1185042, 2013-12-13) and Template:Issues/SVC-6357 (revision 1057662, 2010-10-09); history, by Second Life Wiki contributors, under CC BY-SA 3.0. Last wiki edit: .