Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Current Week Days Display

Date

  • Please log in to reply
1 reply to this topic

#1 Divi

Divi

    Passenger

  • Members
  • 1 posts

Posted 25 September 2013 - 07:13 PM

uhow to display week days  of current week  
<%
 @start = Date.today.beginning_of_week 
 @end = Date.today.end_of_week
%>
 
Like
 
Mon, Tue, Wed . Thu, Fri 
 
 
please how can i achieve this suggest me
 
 


#2 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 25 September 2013 - 07:34 PM

Doing 

(Date.today.beginning_of_week..Date.today.end_of_week).map {|w| w.strftime("%A")}

will give you

=> ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

If instead you'd rather like Mon, Tue and so on, replace the "%A" with "%a":

project> (Date.today.beginning_of_week..Date.today.end_of_week).map {|w| w.strftime("%a")}
=> ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

  • james and MrPepper like this

Blog: http://ohm.sh | Twitter: madsohm





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users