Anyone have anything written already that will convert the 24hr format and return the hour, and am/pm? So 14 hours would give me 2 PM…? If not I’ll start writing… [import]uid: 19193 topic_id: 15091 reply_id: 315091[/import]
get the hours, and if the hours > 12 then hours = hours - 12
will that help?
cheers,
?
[import]uid: 3826 topic_id: 15091 reply_id: 55819[/import]
As Jayant said, although remember to set it to PM in that argument as well. (If > 12 then PM, etc.) [import]uid: 52491 topic_id: 15091 reply_id: 55857[/import]
Here you go :
[code]
holdClock = os.time();
local theTime = display.newText(“12:12:12:am”, 225, 410, nil, 14)
theTime:setTextColor( 255, 255, 255, 255 )
local function clockTimer(event)
myTime = os.time()
_G.duration = _G.duration - 2.5
–Stop audio if duration is reached
if _G.duration == 0 then
audio.stop(1)
end
–print(_G.duration)
if holdTime ~= myTime then
holdTime = myTime;
t = os.date( “*t” )
ampm = “am”;
if t.hour == 12 then
ampm = “pm”;
end
if t.hour < 12 then
ampm = “am”;
end
if t.hour > 12 then
t.hour = t.hour - 12;
ampm = “pm”;
end
if t.hour == 0 then
t.hour = 12;
ampm = “am”
end
local s = string.format( “%2d:%02d:%02d%s”, t.hour, t.min, t.sec, ampm )
–print( s );
theTime.text = s;
end
end
Runtime:addEventListener( “enterFrame”, clockTimer );
[/code] [import]uid: 84637 topic_id: 15091 reply_id: 55932[/import]