Craig White wrote:
> On Sun, 2009-09-27 at 19:26 +0200, Michael .. wrote:
>   
>> hi.
>>
>> I want to format a Integer value to a hour with a preceding zero.(two
>> digits)
>> eg. 8 => 08
>>
>> Exists a Ruby or Rails function for that?
>>
>>     
> ----
> you can easily create your own function and put it into application.rb
> or the helper
>
> myvar < 10 ? "0" + myvar.to_s : myvar.to_s
>
> it must be a string to retain the leading zero

or "%02d" % myvar

Cheers,
Mohit.
9/28/2009 | 1:52 AM.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to