Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get the name of the day from Time.now

860 views
Skip to first unread message

misiek

unread,
Jan 23, 2006, 6:21:58 PM1/23/06
to
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

Antonio Cangiano

unread,
Jan 23, 2006, 6:31:05 PM1/23/06
to

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

misiek

unread,
Jan 23, 2006, 6:50:13 PM1/23/06
to
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

jared...@gmail.com

unread,
Jul 10, 2012, 11:46:53 AM7/10/12
to
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!

Robert Klemme

unread,
Jul 10, 2012, 4:59:44 PM7/10/12
to
On 10.07.2012 17:46, jared...@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 new messages