Hi,
Can some one tell me how to make all numbers display as 2 digits (eg 02 instead of 2) in my perl CGI script?
Thanks, Robert
Hi,
Can some one tell me how to make all numbers display as 2 digits (eg 02 instead of 2) in my perl CGI script?
Thanks, Robert
“Why’d ya wanna go ‘n’ do that, huh” ?
perhaps you could try and do something like this…
if ($num < 10) # if numder is less than 10 (hence only 1 digit)
{ $num = “0”.$num; } # put a 0 in front of it
Dont know if this is what you mean?
The reason I am trying to display 2 digits is for a guestbook script which displays the time of each post but for say 5 past 12 it would display 12:5:00 instead of 12:05:12 which looks far better. I will try your suggestion and post later
Robert
oh oakie doakie
a far easier method would be to do…
$str = sprintf (“%02d:%02d:%02d”, $hour, $min, $sec);
I also need to convert the month so that it is two digits.
Is this code correct
$str = sprintf (“%02d”,$mon);
Thanks, Rob
yep