# Change 1-06-2006 to 1st July 2006 (date formatting)

**URL:** <https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613>\
**Category:** Rails\
**Created:** [June 6, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613 "2006-06-06T16:40:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [June 6, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613/1 "2006-06-06T16:40:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [June 6, 2006, 5:14pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613/2 "2006-06-06T17:14:09Z")

</div>

scott wrote:

> 

See Time#strftime.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [June 7, 2006, 2:57pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613/3 "2006-06-07T14:57:07Z")

</div>

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](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.ch/en/rubybookonline.shtml)

[http://www.ruby-doc.org/docs/ProgrammingRuby/](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

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [June 7, 2006, 5:10pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613/4 "2006-06-07T17:10:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [June 7, 2006, 6:25pm UTC](https://www.ruby-forum.com/t/change-1-06-2006-to-1st-july-2006-date-formatting/62613/5 "2006-06-07T18:25:16Z")

</div>

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](http://api.rubyonrails.org) in the  
ActiveSupport::CoreExtensions:📅:Conversions module.

hth,  
Bill
