Newby issue with the date class

ok i have partial defined like this

<%=
d = Date.today
%>

<%= Date::ABBR_DAYNAMES[d.wday] %>
<%= d.day %>
<%= Date::ABBR_MONTHNAMES[d.mon] %>

now whats annoying is when it renders i get this

2006-06-14 <— why is this being rendered ?
& then my css formatted date below
Tue
22
Jun

Not sure why it printing out the whole date at the top when im assigning
it to a variable.

anyone any idea on what im doing wrong above or is this simply running
as expected

thanks
pete

<%= … that means display the results of the code to the browser.
You want

<% d = Date.today %>

Jeremy

Hi Pete,

Pete Gajria wrote:

is this simply running
as expected (?)

It’s doing exactly what you told it to do :wink:

Under the MVC paradigm, you should be doing the assignment in your
controller and making the result available to your view via an instance
variable. Move ‘d = Date.today’ to your controller action, changing ‘d’
to
@d’ (else your view won’t have access to it). Then in your view, use
@d.wday, @d.day, etc.

If, for some reason, you really, really, really need to do the
assignment in
your view, use <%… rather than <%=…

hth,
Bill