Forum: Ruby on Rails change 1-06-2006 to 1st July 2006 (date formatting)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
scott (Guest)
on 2006-06-06 18:40
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
Daniel B. (Guest)
on 2006-06-06 19:14
(Received via mailing list)
scott wrote:
>
>
See Time#strftime.

Regards,

Dan
Bill W. (Guest)
on 2006-06-07 16:57
(Received via mailing list)
Daniel B. 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 (Guest)
on 2006-06-07 19:10
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
Bill W. (Guest)
on 2006-06-07 20:25
(Received via mailing list)
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
This topic is locked and can not be replied to.