This script will tell the time in AM/PM time or 24 hour time for ether of the four USA Time Zones and also tells the date and what day of the week it is. I was going to put this on the wiki but I couldn't figure it out. // Time Script by CaseyRedDragon Wise
// feel free to IM me if you have any questions or comments
integer dateoff;
string smin;
string sseconds;
string timeofday;
string time;
//Set timezone to the number corresponding to the time zone you want
//Pacific Time Zone = 0
//Mountain Time Zone = 1
//Central Time Zone = 2
//Eastern Time Zone = 3
integer timezone = 3;
//Set type to "standard" for AM/PM Time or set to "military" for Military Time
string type = "standard";
string uStamp2WeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay ){
return llList2String ( ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"],
(vIntYear + (vIntYear >> 2) - ((vIntMonth < 3) & !(vIntYear & 3)) + vIntDay
+ (integer)llGetSubString( "_033614625035", vIntMonth, vIntMonth )) % 7 );
}
default
{
state_entry()
{
llSetTimerEvent(1.0);
}
timer()
{
integer seconds = llFloor(llGetWallclock());
//llSay(0, (string)seconds);
integer min = llFloor(seconds/60);
seconds = seconds - (min*60);
integer hour = llFloor(min/60);
min = min - (hour*60);
hour = hour + timezone;
if(hour >= 24) {hour = hour - 24;}
integer mili = hour;
if(hour < 12) {timeofday = "AM";}
else {timeofday = "PM";}
if(hour > 12) {hour = hour - 12;}
if(hour == 0) {hour = 12;}
string shour = (string)hour;
if(min < 10) {smin = "0"+(string)min;}
else { smin = (string)min;}
if(seconds < 10) { sseconds = "0"+(string)seconds;}
else {sseconds = (string)seconds;}
if(type == "standard") {
time = shour + ":" + smin + ":" + sseconds + " " + timeofday; }
if(type == "military") {
time = (string)mili + ":" + smin + ":" + sseconds; }
list timepart = llParseString2List(llGetTimestamp(), ["T", ":"], []);
integer uhour = (integer)llList2String(timepart, 1);
if(uhour < 12 && mili > 12) { // -1 day
dateoff = 1; }
else {
dateoff = 0; }
list dateComponents = llParseString2List(llGetDate(), ["-"], []);
integer year = (integer)llList2String(dateComponents, 0);
integer month = (integer)llList2String(dateComponents, 1);
integer day = (integer)llList2String(dateComponents, 2);
day = day - dateoff;
string date = uStamp2WeekdayStr(year, month, day) + " " + (string)month + "-" + (string)day + "-" + (string)year;
string datetime = time + "\n" + date;
llSetText(datetime, ZERO_VECTOR, 1.0);
}
}