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...
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Convert Hours to 12 hour format...
get the hours, and if the hours > 12 then hours = hours - 12
will that help?
cheers,
?:)
As Jayant said, although remember to set it to PM in that argument as well. (If > 12 then PM, etc.)
Here you go :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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 ); |
views:1382 update:2011/10/10 21:27:38
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
SPAM Forum Topics
Facebook Connect in the Simulator
Always random numbers
How do I know when all purchases have been restored?
Unable to set headers with Async http network.request
Another Director alternative - Stripped down Director Class in 24 lines of code
New version 2.0 of "Depth" (free application)
How to open Lime?
Is DocumentsDirectory Content Stored on SD Card?
Does the Application Loader perform a codesign verification?
Facebook Connect in the Simulator
Always random numbers
How do I know when all purchases have been restored?
Unable to set headers with Async http network.request
Another Director alternative - Stripped down Director Class in 24 lines of code
New version 2.0 of "Depth" (free application)
How to open Lime?
Is DocumentsDirectory Content Stored on SD Card?
Does the Application Loader perform a codesign verification?
corona forums © 2003-2011