Hi, I have a few dates coming from the datebase in the format ''DD-MM-YYYY'' How can I change this in to a more human readable format? such as 1st July 2006 Thanks Scott -- Posted via http://www.ruby-forum.com/.
Daniel Berger
2006-Jun-06 15:12 UTC
[Rails] change 1-06-2006 to 1st July 2006 (date formatting)
scott wrote:> Hi, > > I have a few dates coming from the datebase in the format ''DD-MM-YYYY'' > > How can I change this in to a more human readable format? > > such as 1st July 2006 > > Thanks > Scott > >See Time#strftime. Regards, Dan
Bill Walton
2006-Jun-07 08:53 UTC
[Rails] change 1-06-2006 to 1st July 2006 (date formatting)
Daniel Berger wrote:> scott wrote: >> >> I have a few dates coming from the datebase in the format ''DD-MM-YYYY'' >> >> How can I change this in to a more human readable format? >>> See Time#strftime.Just in case you haven''t got it bookmarked yet, you can see Time#strftime (and a lot of other Ruby you''re going to have questions about) at: http://www.rubycentral.com/book/ref_c_time.html The search capabilities at rubycentral have been a source of motivation for some and there are sites that offer the same content with additional capabilities. A couple are (and there are others) http://www.ruby.ch/en/rubybookonline.shtml http://www.ruby-doc.org/docs/ProgrammingRuby/ I find these and other sites more helpful after having bought the book itself, and still very often just grab the book when I''m thinking through how to tackle a challenge. hth, Bill
scott
2006-Jun-07 15:10 UTC
[Rails] Re: change 1-06-2006 to 1st July 2006 (date formatting)
thanks for the links, totally new to ruby, so they should come in useful After a bit of reading I have managed to get this to work <%date = Time.now %> <%= date.strftime("%d %B %Y") %> the Value @pMin = yyyy-mm-dd eg 2006-06-06 how can I put this in to a time obeject to use the strftime function with it? Thanks Scott -- Posted via http://www.ruby-forum.com/.
Bill Walton
2006-Jun-07 16:24 UTC
[Rails] Re: change 1-06-2006 to 1st July 2006 (date formatting)
Hi Scott, scott wrote:> the Value @pMin = yyyy-mm-dd eg 2006-06-06 > > how can I put this in to a time obeject to use > the strftime function with it?I think you''ll find what you want at http://api.rubyonrails.org in the ActiveSupport::CoreExtensions::Date::Conversions module. hth, Bill