ruby: how to get day of the week for a given date | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

ruby: how to get day of the week for a given date

Dear all, How to get weekday for a given date i.e. if we give Date.now how to get the weekday i.e. monday.....sunday

9th Nov 2016, 4:28 AM
Ravi Katta
1 Answer
0
It's ok I got it Solution: require 'date' d = Date.today weekday = Date.parse( '#{d.day} #{d.month} #{d.year}' ) ####******* or for custom date pass -> Date.parse('3rd Feb 2001') ******** puts weekday.strftime('%A') Output: Monday
9th Nov 2016, 4:50 AM
Ravi Katta