# Problem changing datetime format

**URL:** <https://www.ruby-forum.com/t/problem-changing-datetime-format/84995>\
**Category:** Ruby\
**Created:** [February 9, 2007, 2:40am UTC](https://www.ruby-forum.com/t/problem-changing-datetime-format/84995 "2007-02-09T02:40:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@reed](https://www.ruby-forum.com/u/reed)\
**Post date:** [February 9, 2007, 2:40am UTC](https://www.ruby-forum.com/t/problem-changing-datetime-format/84995/1 "2007-02-09T02:40:40Z")

</div>

I am trying to format some datetimes like this…2007, February the  
9th, 6:30pm

I have the following which gets me part way there.

ActiveSupport::CoreExtensions::Time::Conversions::DATE\_FORMATS.update(:my\_date\_format  
=\> “%Y, %d %B, %I:%M%p”)

There are 2 problems

1. There is no “th” formatter so that I get 1st, 2nd, 3rd, 4th, 5th,  
etc.
2. PM is in uppercase and I would prefer it in lower.

TIA

---

<div class="post-metadata">

**Author:** ![reed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@reed](https://www.ruby-forum.com/u/reed)\
**Post date:** [February 9, 2007, 4:39am UTC](https://www.ruby-forum.com/t/problem-changing-datetime-format/84995/2 "2007-02-09T04:39:47Z")

</div>

On Feb 8, 2007, at 8:40 PM, reed wrote:

> 1. There is no “th” formatter so that I get 1st, 2nd, 3rd, 4th, 5th,  
> etc.
> 2. PM is in uppercase and I would prefer it in lower.
> 
> TIA

Roll your own a bit:

[http://api.rubyonrails.org/classes/Inflector.html#M001091](http://api.rubyonrails.org/classes/Inflector.html#M001091)  
(part of ActiveSupport)

Just .downcase the AM/PM

You’re asking on the Ruby list, but you clearly have ActiveSupport.  
If this is more of a Rails question, you may get more response on the  
Rails list (removed\_email\_address@domain.invalid).

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![reed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@reed](https://www.ruby-forum.com/u/reed)\
**Post date:** [February 9, 2007, 6:50am UTC](https://www.ruby-forum.com/t/problem-changing-datetime-format/84995/3 "2007-02-09T06:50:55Z")

</div>

On Feb 9, 4:38 pm, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (part of ActiveSupport)  
> removed\_email\_address@domain.invalid  
> Thanks for that, I will repost on the rails group.
