How do I create a two digit time display

Get help using Construct 2

Post » Wed Aug 26, 2015 3:35 pm

Hi everyone,

I am currently using "Time: " & floor(Timer / 60 % 60) & "m" & floor(Timer % 60) & "s" to display a time readout in game. I would like the time to be formated like 00:00 instead of 0:0.

I have tried zeropad, but the results were a little unexpected.

Could anyone make any suggestions?

Thanks!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Wed Aug 26, 2015 3:38 pm

I had the same need and ended up customizing rex's date plugin.
https://drive.google.com/file/d/0B-xiqK ... sp=sharing

The function is "FormatTimer" and it takes in milliseconds as an input.

There are other time formatters in there if you need a clock timer, instead of a countdown timer (which is what FormatTimer is for).
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Aug 26, 2015 4:30 pm

zeropad should work, maybe you did not use it correctly ?

Code: Select all
"Time: " & zeropad(floor(Timer / 60 % 60),2) & "m" & zeropad(floor(Timer % 60),2) & "s"
B
75
S
31
G
27
Posts: 1,014
Reputation: 20,763

Post » Wed May 10, 2017 4:23 pm

You also could use:
Code: Select all
"Time: " & right("00" & timer,2) & "m" & right("00" & timer,2)& "s"
B
8
S
1
Posts: 86
Reputation: 618


Return to How do I....?

Who is online

Users browsing this forum: lemonizer and 1 guest