Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?

by tenatious (Beadle)
on Aug 21, 2000 at 05:29 UTC ( [id://28758]=note: print w/replies, xml ) Need Help??


in reply to Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?

The above answers are adequate, but I'd like to add that all you have to do is treat the 600 like a string instead of a number. So if you wanted to make a "24 hour" variable, all you'd have to do is something like;
$time = 600; ($time = "0".$time) if ($time < 1000);
  • Comment on Re: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
  • Download Code

Replies are listed 'Best First'.
Re: Answer: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
by I0 (Priest) on Dec 26, 2000 at 06:39 UTC
    what if $time < 100?
Re: Answer: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
by eg (Friar) on Dec 26, 2000 at 21:50 UTC

    Heh. Then, I suppose, the code becomes:

    $time = 600; ($time = "0".$time) if ($time < 1000); ($time = "0".$time) if ($time < 100); ($time = "0".$time) if ($time < 10);

    p.s. Don't do this -- stick with sprintf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://28758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-16 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found