One possible way of doing it could be:
// Mok Rau's real simple digital clock display script
//------------------------------------------------------
// Drop this script into a prim and touch it. The script
// will send a message visible only to the owner in the
// format "The time is 18:30 SLT".
// Oct/08
// Uncomment one of the two next sentences below to choose
// the display format: 24-h (23:30) 12-h or AM-PM (11:30pm)...
string sFormat = "24H"; // 24-hour format
//sformat = "AMP"; // 12-hour format with AM/PM
// Uncomment one of the two next sentences to choose between local
// simulator time or second life time
string sTimeZone = "SLT"; // Second Life Time
//sTimeZone = "LOC"; // Local time
default {
state_entry(){
llOwnerSay("Clock ready. Format "+sFormat+" "+sTimeZone);
}
touch_start(integer i){
float nTime = 0;
if (sTimeZone == "SLT"

{
nTime = llGetWallclock();
}else{
nTime = llGetTimeOfDay();
}
integer iHour = (integer)(nTime / 3600);
integer iMin = (integer)(nTime / 60) % 60;
string sAmPm = "";
string sMin = (string)iMin;
if (iMin < 10){
sMin = "0" + sMin;
}
if (sFormat == "AMP"

{
if (iHour >= 12){
iHour -= 12;
}
if (nTime > 43200){
sAmPm = "pm";
}else{
sAmPm = "am";
}
}
llInstantMessage(llDetectedKey(0),"The time is "+(string)iHour+":"+sMin+sAmPm+" "+sTimeZone);
}
}
Edit-- sorry to clutter. Went inworld to check the code and didn't notice the other replies...