I want to display date and time in view as "August 7, 2009 at 10:22:02 am". Presently it is displaying in view as "2009-08-07 10:22:02 UTC". Can anyone tell to format date and time. -- Posted via http://www.ruby-forum.com/.
2009/8/8 Aashish Kiran <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > I want to display date and time in view as "August 7, 2009 at 10:22:02 > am". Presently it is displaying in view as "2009-08-07 10:22:02 UTC". > Can anyone tell to format date and time.Have a look at strftime. (Did you try googling for ruby format date time, Google is usually quicker than posting here.). Colin> -- > Posted via http://www.ruby-forum.com/. > > > >
THIS IS THE SOLUTION TRY THIS
<%=DateTime.now.strftime("%B %d %Y")%> <%=
DateTime.now.strftime("%I:
%M%P " ) %>
On Aug 8, 3:19 pm, Colin Law
<clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> 2009/8/8 Aashish Kiran
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:
>
>
>
> > I want to display date and time in view as "August 7, 2009 at
10:22:02
> > am". Presently it is displaying in view as "2009-08-07
10:22:02 UTC".
> > Can anyone tell to format date and time.
>
> Have a look at strftime.
> (Did you try googling for ruby format date time, Google is usually
> quicker than posting here.).
>
> Colin
>
> > --
> > Posted viahttp://www.ruby-forum.com/.
If you want it formatted this way all the time, you might also want to consider setting a format in Time::DATE_FORMATS via an initializer. In your case, you''d drop this code into a file in config/initializers (say, date_formats.rb): Time::DATE_FORMATS[:default] = "%A %d %Y at %H:%M:%S" That should be close to what you want - look at the docs for strftime for more of the % symbols. --Matt Jones On Aug 8, 5:45 am, Aashish Kiran <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I want to display date and time in view as "August 7, 2009 at 10:22:02 > am". Presently it is displaying in view as "2009-08-07 10:22:02 UTC". > Can anyone tell to format date and time. > -- > Posted viahttp://www.ruby-forum.com/.