llGetUnixTime
function
Function syntax
integer llGetUnixTime();- Returns
integer- Energy
- 10
Returns an integer that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC from the system clock (Unix time).
integer result = llGetUnixTime();Caveats
Section titled “Caveats”- Time codes outside 1901-12-13 20:45:52 UTC and 2038-01-19 03:14:08 UTC cannot be represented in LSL due to its use of signed 32-bit integers for Unix times. Scripts that rely on this function after January 19, 2038 may have logical errors.
- Consider
llGetTimestampinstead, which will correctly report time through 2038. - Lua scripts (not including LSL scripts compiled for the Luau VM) do not have this limitation with
os.time(), since it returns a 64-bit number and will correctly represent time through the likely heat death of the universe.
Examples
Section titled “Examples”Example 1
// Reset trackerinteger 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); }}Helper functions
Section titled “Helper functions”Helper Functions:
Section titled “Helper Functions:”- Unix2StampLst — Converts Unix Time stamp to a list. ex: 1234567890 to [2009, 2, 13, 23, 31, 30]
- Stamp2UnixInt — Converts date to Unix Time stamp. ex: [2009, 2, 13, 23, 31, 30] to 1234567890
- uuLinuxTime — Converts date to Unix Time stamp (from Linux kernel’s sources)
- Unix2WeekdayStr — Gets the weekday from a Unix Time stamp. ex: “Friday” from 1234567890
- Unix2PST_PDT — Converts Unix Time stamp to an SLT date/time string with PST or PDT indication as appropriate
- Unix2GMTorBST — Converts Unix Time stamp to a UK date/time string with GMT or BST indication as appropriate
Known issues
Section titled “Known issues”From the issue templates included by the wiki article:
- BUG-4703 (bug): Year 2038 problem
- SVC-6357 (nf): llGetUnixTimeNanos() - greater precision timing mechanism
See also
Section titled “See also”Functions
Section titled “Functions”llGetTimestamp— Human Readable UTC Date and timellGetDate— Human Readable UTC DatellGetTime— Elapsed script-time.
Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.