LlGetRegionTimeOfDay: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
mNo edit summary
Fixed some incorrect references about this function returning region uptime - which is not the case at all. See https://feedback.secondlife.com/scripting-bugs/p/llgettimeofday-fails-to-return-server-up-time
 
Line 5: Line 5:
|func_energy=10.0
|func_energy=10.0
|return_type=float
|return_type=float
|func_footnote=By default (without custom environment settings), Second Life day cycles are 4 hours long (3 hours of light, 1 hour of dark). The sunrise and sunset time varies slowly.
|func_footnote=Will return the same result as [[llGetTimeOfDay]] on parcels that use region environment settings.
By default (without custom environment settings), Second Life day cycles are 4 hours long, but can be configured to anywhere between 4 and 168 hours long.
|func_desc
|func_desc
|return_text=that is the time in seconds with subsecond precision since Second Life midnight (per the region-scoped day cycle settings) or region up-time (time since when the region was brought online/rebooted); whichever is smaller. If the region is configured so the sun stays in a constant position, then the returned value is the region up-time.
|return_text=that is the time in seconds with sub-second precision since Second Life midnight (per the region-scoped day cycle settings).
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples=<source lang="lsl2">//Time will be less than 4 hours unless the sun is locked.
|examples=<source lang="lsl2">default
default
{
{
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
         float tod = llGetRegionTimeOfDay( );
         float tod = llGetTimeOfDay( );
         llOwnerSay("Time since last region restart or SL midnight (based on SL 4 hour day):");
         llOwnerSay("Time since midnight on current region:");
         integer hours = ((integer)tod / 3600) ;
         integer hours = ((integer)tod / 3600) ;
         integer minutes = ((integer)tod / 60) - (hours * 60);
         integer minutes = ((integer)tod / 60) - (hours * 60);

Latest revision as of 09:52, 22 July 2026

Summary

Function: float llGetRegionTimeOfDay( );
0.0 Forced Delay
10.0 Energy

Returns a float that is the time in seconds with sub-second precision since Second Life midnight (per the region-scoped day cycle settings).

Will return the same result as llGetTimeOfDay on parcels that use region environment settings. By default (without custom environment settings), Second Life day cycles are 4 hours long, but can be configured to anywhere between 4 and 168 hours long.

Examples

default
{
    touch_start(integer total_number)
    {
        float tod = llGetTimeOfDay( );
        llOwnerSay("Time since midnight on current region:");
        integer hours = ((integer)tod / 3600) ;
        integer minutes = ((integer)tod / 60) - (hours * 60);
        llOwnerSay((string) tod + " seconds which is "+(string) hours+"h "+(string) minutes+"m"); 
    }
}

See Also

Functions

•  llGetSunDirection
•  llGetTimeOfDay

Deep Notes

Signature

function float llGetRegionTimeOfDay();