Problem changing datetime format

R

reed

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
 
R

Rob Biedenharn

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

Roll your own a bit:

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 ([email protected]).

-Rob

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top