get the name of the day from Time.now

  • Follow


how can I get the name of the day from Time.now
Time.now.day is a number I would like to for example Mon...
thx
0
Reply michaelaugustyniak (57) 1/23/2006 11:21:58 PM

misiek wrote:
> how can I get the name of the day from Time.now
> Time.now.day is a number I would like to for example Mon...
> thx

Hi misiek,
you can use strftime.

For example:

t = Time.now
puts t.strftime("%a")  #=> Mon
puts t.strftime("%A")  #=> Monday

ri strftime, will give you the complete list of options.

Cheers,
Antonio
-- 
Antonio Cangiano
My Ruby blog: http://www.antoniocangiano.com
0
Reply acangianohatesspam (5) 1/23/2006 11:31:05 PM


Antonio Cangiano wrote:
> misiek wrote:
> 
>> how can I get the name of the day from Time.now
>> Time.now.day is a number I would like to for example Mon...
>> thx
> 
> 
> Hi misiek,
> you can use strftime.
> 
> For example:
> 
> t = Time.now
> puts t.strftime("%a")  #=> Mon
> puts t.strftime("%A")  #=> Monday
> 
> ri strftime, will give you the complete list of options.
> 
> Cheers,
> Antonio


thank you it was super easy
0
Reply michaelaugustyniak (57) 1/23/2006 11:50:13 PM

On Monday, January 23, 2006 6:50:13 PM UTC-5, misiek wrote:
> Antonio Cangiano wrote:
> > misiek wrote:
> > 
> >> how can I get the name of the day from Time.now
> >> Time.now.day is a number I would like to for example Mon...
> >> thx
> > 
> > 
> > Hi misiek,
> > you can use strftime.
> > 
> > For example:
> > 
> > t = Time.now
> > puts t.strftime("%a")  #=> Mon
> > puts t.strftime("%A")  #=> Monday
> > 
> > ri strftime, will give you the complete list of options.
> > 
> > Cheers,
> > Antonio
> 
> 
> thank you it was super easy

Hi,

What do you mean by "ri strftime"? How do I get a complete list?

Thanks!
0
Reply jared.flack (1) 7/10/2012 3:46:53 PM

On 10.07.2012 17:46, jared.flack@gmail.com wrote:

> What do you mean by "ri strftime"? How do I get a complete list?

More correctly "ri Time#strftime", for all methods see "ri Time".

Kind regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/


0
Reply shortcutter (5766) 7/10/2012 8:59:44 PM

4 Replies
52 Views

(page loaded in 0.075 seconds)

Similiar Articles:













7/29/2012 9:05:38 AM


Reply: