[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

month and day

jabowen

7/17/2007 3:26:00 PM

Assuming that to day it January 1 2007 when the
following code is and the response is 1. Is there a
way to get back 01? I?m also looking to get 01 for
the day. It looks like %m and %d is what I?m looking
for but I don?t know how to implement the formatting.

t = Time.now
puts t.mon
=> 1

Jeff



____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid...

1 Answer

Todd Benson

7/17/2007 3:34:00 PM

0

On 7/17/07, Jeffrey Bowen <ja_bowen@yahoo.com> wrote:
> Assuming that to day it January 1 2007 when the
> following code is and the response is 1. Is there a
> way to get back 01? I'm also looking to get 01 for
> the day. It looks like %m and %d is what I'm looking
> for but I don't know how to implement the formatting.
>
> t = Time.now
> puts t.mon
> => 1

irb> '%02d' % Time.now.mon
07
=> nil

Todd