Search Tutorials
How to make 2 digit time display. Simple.Just a couple weeks ago I had to make a clock and calendar for a screensaver. And there is a problem that Flash returns minutes, seconds and any other time-related numbers as they are, e.g. 12:5:7. So the task here was to make this number into 12:05:07. I happened to read a tutorial which suggested cheking each number separately and then setting it to two-digit if neccesarry. It looked like this: if minute == 1 then set it to minute = 01, else if second == 1 then set it 01 etc, etc... So to save any of you, who may follow a tute to do this, some extra time and annoying script duplications, may I suggest the following: minute = (mydate.getMinutes());
if (Length(minute) == 1) {
minute = "0" add minute;
}
second = (mydate.getSeconds());
if (Length(second) == 1) {
second = "0" add second;
}
Any explanation needed? What we do here is get the time, stick it into a variable, check the length (amount of characters) in that variable and in case this length is == to 1, add a zero right before it... and a few lines get the job done! Good luck!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|