string llGetDate()
Returns the current
UTC date as
YYYY-MM-DD (with padding zeros).
See also
llGetTimestamp.
Example
This function returns the current date in
PST. It works just like the
llGetDate function by returning a
string of the PST date in
YYYY-MM-DD format, so once this is added to a script, it can be used instead of
llGetDate. (Note: this does not observe Daylight Savings Time. For a script that does that, see
this forum thread.) <-This note is wrong, since llGetWallclock observes DST this script will correctly observe DST.
string GetPSTDate()
{
string DateToday = "";
string DateUTC = llGetDate();
if (llGetGMTclock() - llGetWallclock() < 0) //if it's negative then the date has changed.
{
integer year = (integer)llGetSubString(DateUTC, 0, 3);
integer month = (integer)llGetSubString(DateUTC, 5, 6);
integer day = (integer)llGetSubString(DateUTC, 8, 9);
if (day == 1) // if day is the 1st of a month, fix the date
{
if (month == 1) // if it is January
{
year = year - 1; // wind back the year
month = 12; // set the month to December
day = 31; // set to last day of December
}
else
{
month = month - 1; // wind back one month
if(month == 2)
day = 28 + !(year % 4) - !(year % 100) + !(year % 400);
else
day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
}
}
else
day = day - 1;
if(month < 10)
DateToday = "0";
DateToday+=(string)month + "-";
if(day < 10)
DateToday += "0";
DateToday+=(string)day;
return (string)year + "-" + DateToday;
}
return DateUTC;
}
Functions |
Time |
Simulator