Unsolved How do I make a number 2 digits
-
I am doing a countdown timer and I would like it in the format mm:ss. I have the code written to do the countdown and pull out a minute and second variable. The problem is when I use Text in QML and put my variable in for text: when it gets below 10 I get a single digit number. Is there anyway to get 01 instead of 1?
-
Hi,
A quick and simple way:
function padValue(value) { if (value < 10) { value = "0" + i; } return value; }
Hope it helps
-
Hi
QML noob here but i was wondering if you can just write a JS function for it ?function pad(n) { return (n < 10) ? ("0" + n) : n; }
hehe. a second too late. Yep it seems you can :)
-
Thanks everyone I ended up doing an ugly hack I am not proud of. I put another Text element that displays "0" and its only visible when my minute number is less than 10.
-