Get the name of the day from Time.now

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

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 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs