Forum: Ruby get the name of the day from Time.now

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
misiek (Guest)
on 2006-01-24 19:01
(Received via mailing list)
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 C. (Guest)
on 2006-01-24 19:05
(Received via mailing list)
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
misiek (Guest)
on 2006-01-24 19:05
(Received via mailing list)
Antonio C. wrote:
> 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
This topic is locked and can not be replied to.