Difference between revisions of "LlGetUnixTime"

From Second Life Wiki
Jump to navigation Jump to search
 
(22 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{LSL_Function|func_id=316|func_sleep=0.0|func_energy=10.0|func=llGetUnixTime|sort=GetUnixTime|return_type=integer|func_desc|return_text=that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC from the system clock.|spec|caveats=*{{Wikipedia|Year_2038_problem}}|examples|helpers|notes}}[[Category:LSL_Stub]]
{{LSL Function
|inject-2={{Issues/BUG-4703}}{{Issues/SVC-6357}}
|func_id=316|func_sleep=0.0|func_energy=10.0
|sort=GetUnixTime|func=llGetUnixTime|return_type=integer
|func_footnote
|func_desc
|return_text=that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 {{Wikipedia|Coordinated Universal Time|UTC}} from the system clock.
|spec
|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.
|constants
|examples=<source lang="lsl2">
// 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);
    }
}
</source>
|helpers=
=== Helper Functions: ===
{{{!}}
{{LSL DefineRow||[[Unix2StampLst]]|Converts Unix Time stamp to a list. ex: 1234567890 to [2009, 2, 13, 23, 31, 30]}}
{{LSL DefineRow||[[Stamp2UnixInt]]|Converts date to Unix Time stamp. ex: [2009, 2, 13, 23, 31, 30] to 1234567890}}
{{LSL DefineRow||[[uuLinuxTime]]|Converts date to Unix Time stamp (from Linux kernel's sources)}}
{{LSL DefineRow||[[Unix2WeekdayStr]]|Gets the weekday from a Unix Time stamp. ex: "Friday" from 1234567890}}
{{LSL DefineRow||[[Unix2PST_PDT]]|Converts Unix Time stamp to an SLT date/time string with PST or PDT indication as appropriate}}
{{LSL DefineRow||[[Unix2GMTorBST]]|Converts Unix Time stamp to a UK date/time string with GMT or BST indication as appropriate}}
{{!}}}
|also_functions=
{{LSL DefineRow||[[llGetTimestamp]]|Human Readable UTC Date and time}}
{{LSL DefineRow||[[llGetDate]]|Human Readable UTC Date}}
{{LSL DefineRow||[[llGetTime]]|Elapsed script-time.}}
|also_events
|also_tests={{LSL DefineRow||[[llGetUnixTime/test|llGetUnixTime Conformance Test]]|}}
|also_articles
|notes
|permission
|negative_index
|cat1=Time
|cat2
|cat3
|cat4
}}

Latest revision as of 04:33, 10 September 2024

Summary

Function: integer llGetUnixTime( );
0.0 Forced Delay
10.0 Energy

Returns an integer that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 "Wikipedia logo"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:

•  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

See Also

Functions

•  llGetTimestamp Human Readable UTC Date and time
•  llGetDate Human Readable UTC Date
•  llGetTime Elapsed script-time.

Deep Notes

Tests

•  llGetUnixTime Conformance Test

Signature

function integer llGetUnixTime();