Syntax

integer llGetUnixTime();

Forced delay: 0.0 seconds. Energy: 10.0.

Return value

Returns an integer that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC from the system clock.

Caveats

Time codes before the year 1902 or past the end of 2037 are limited due to the size of LSL's 32-bit integers. As of writing (2024) this is just 14 years away now and any scripts relying on this function may have logical errors.

Examples

// Reset tracker
integer BOOT_TIME;
default
{
    state_entry()
    {
        BOOT_TIME = llGetUnixTime(); 
        llSetTimerEvent(0.1);
    }
    
    timer()
    {
        llSetText((string)(llGetUnixTime() - BOOT_TIME) + " Seconds since boot.\n\n ", <1,0,0>, 1.0);
        llSetTimerEvent(1);
    }
}

Useful snippets

Helper Functions:

Unix2StampLstConverts Unix Time stamp to a list. ex: 1234567890 to [2009, 2, 13, 23, 31, 30]
Stamp2UnixIntConverts date to Unix Time stamp. ex: [2009, 2, 13, 23, 31, 30] to 1234567890
uuLinuxTimeConverts date to Unix Time stamp (from Linux kernel's sources)
Unix2WeekdayStrGets the weekday from a Unix Time stamp. ex: "Friday" from 1234567890
Unix2PST_PDTConverts Unix Time stamp to an SLT date/time string with PST or PDT indication as appropriate
Unix2GMTorBSTConverts Unix Time stamp to a UK date/time string with GMT or BST indication as appropriate

See also

Functions

Deep notes

Issues

Tests