Format time to Hour Minute Seconds like 00:00:00

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

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited June 2014

    @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.

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    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

  • ChampachanChampachan Member Posts: 21

    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.

Sign In or Register to comment.