Format time to Hour Minute Seconds like 00:00:00
Champachan
Member Posts: 21
Hello ppl,
I am trying to format some time in Hour Minute Seconds to 00:00:00, it all works but the second digit of the larger hour is doubling up for some reason.
Here is the code:
floor(floor(( game.My Timer )/3600)/10)..floor(( game.My Timer )/3600)..":"..floor(floor(( game.My Timer %3600)/60)/10)..floor((floor( game.My Timer %3600)/60)%10)..":"..floor(( game.My Timer %60)/10)..floor( game.My Timer %10)
Has anyone got any clues?
Comments
@Champachan, here is a leaner method
padInt(game.MyTimer/3600,2)..":".. padInt(mod(game.MyTime,3600)/60,2)..":".. padInt(mod(game.MyTime,60),2)
Note that % will be depreciated at some point, so I used the mod() function instead.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Hi @Champachan
First to say, you've put this thread in the wrong Forum - no worries, it's not very clear this one.... "Coding/Programming or Logic Services" really means "Coding/Programming Services or Logic Services". I'll move it to "Working with GS (Mac)" for you.
OK, your hrs mins secs code: there's a few slight variations on a theme for this but in the main they're pretty much the same. But despite the variations, I think there's a few hiccups with your version... so try the following instead:
floor(floor(game.My Timer/3600)/10)..floor(floor(game.My Timer/3600)%10)..":"..floor(floor((game.My Timer/3600)/60)/10)..floor((floor(game.My Timer%3600)/60)%10)..":"..floor((game.My Timer%60)/10)..floor( game.Time %10)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks Hopscotch & gyroscope, I have used the padInt mod method, and it works a treat.
Thanks for your help too gyroscope it works too but I am afraid to use % if it will be depreciated at some point. Also thanks for cleaning up my forum cat.