Don't click here unless you want to be banned.

LSL Wiki : llGetGMTclock

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl801.us.archive.org
float llGetGMTclock()

Gets the time in seconds since midnight in GMT/UTC.

GMT time is very useful when synchronizing with systems outside of SL via email or RPC. It is an absolute and international measure of time that does not change throughout the year. It isn't so great when trying to make a wall clock for Second Life that observes Daylight Saving Time. Creating local time from this function is a matter of adding the correct offset to GMT, a requirement complicated by yearly and national differences of when Daylight Saving Time goes into and out of effect.

The following function gets a clock for any time zone in the world, with a military time toggle.
(by DanielLuchador)
(note by CeeqLaborde - I actually think this breaks bad when timezone takes the gmt time over 23:59:59)

string clock(float timezone, integer military)
{
    integer raw = (integer)(llGetGMTclock() + (timezone * 3600));
    integer shiftraw = raw;

      //  3600 = seconds in an hour
      // 86400 = seconds in 24 hours
    if((timezone * 3600) + raw > 86400)
    {
        shiftraw = raw - 86400;
    }
    else if((timezone * 3600) + raw < 0)
    {
        shiftraw = raw + 86400;
    }
    
    integer hours = shiftraw / 3600;
    integer minutes = (shiftraw % 3600) / 60;
    integer seconds = shiftraw % 60;
    string ampm;
    
    //non-military time adjustments
    if(!military)
    {
          // 43200 = seconds in 12 hours
        if(shiftraw < 43200)
        {
            ampm = " AM";
        }
        else
        {
            ampm = " PM";
            hours -= 12;
        }
    }
    
    string shours = (string)hours;
    string sminutes = (string)minutes;
    string sseconds = (string)seconds;
    
    //add zeros to single digit minutes/seconds
    if(llStringLength(sminutes) == 1)
    {
        sminutes = "0" + sminutes;
    }
    if(llStringLength(sseconds) == 1)
    {
        sseconds = "0" + sseconds;
    }
    
    string time = shours + ":" + sminutes + ":" + sseconds + ampm;
    
    return time;
}

For a monotonic time source with seconds precision use llGetUnixTime

See also: llGetWallclock (returns time in seconds in the PST/PDT time zone).


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Time | Simulator
Comments [Hide comments/form]
GMT clock is used in aviation, and it's offset also allows you to do time zone offset based on time zones without US standard daylight savings time, thus, Zulu is a useful time standard, just because it's not usable in day to day operations (AKA to the normal non-technical user) it's usable for more technical users for various reasons. - IceBrodie
-- IceBrodie (2004-09-07 01:59:10)
doesnt work...before midnight gives negative time.....timezone*3600 double-bug..;)
-- e212-246-66-183.elisa-laajakaista.fi (2007-03-25 14:11:15)
it is not monotonic since it is reset on each midnight, so i removed that sentence and put it to llGetUnixTime instead. - BerndElswit
-- p54A34385.dip0.t-ipconnect.de (2007-04-01 12:01:01)
Attach a comment to this page: