month and day

J

Jeffrey Bowen

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=396545469
 
T

Todd Benson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top