AM/PM select

I have a customer that has a request that the select_datetime fields
have AM/PM selectors instead of 24 hour time.
The rails time and datetime selects seem to only support 24 hour time.
I can’t seem to find any information on this. i was wondering if
there is already a solution out there, or will i have to roll my own?

Sean W.
master nerd of
i heart squares, inc.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
http://www.iheartsquares.com

Sean W. wrote:

I have a customer that has a request that the select_datetime fields
have AM/PM selectors instead of 24 hour time.
The rails time and datetime selects seem to only support 24 hour time.
I can’t seem to find any information on this. i was wondering if
there is already a solution out there, or will i have to roll my own?

Sean W.
master nerd of
i heart squares, inc.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
http://www.iheartsquares.com

there is already solution out there… and dont need much coding also…
cos this is only a formatting question…

using the strftime method would solve the trick!
options to use are just like the usual sql commands…

eg.
my_date.strftime(“%Y-%m-%d–%H:%M”) will generate 2006-06-09–17:30
my_date.strftime(“%Y-%m-%d–%I:%M%p”) will generate 2006-06-09–5:30PM

hope this helps!

that’s all fine if it’s just the var my_date you’re trying to format,
but how would you go about modifying the datetime_select tag?

<%= datetime_select ‘bug’, ‘added_at’ %>

I can’t get it to work with .strftime in there…

On 6/8/06, Sean W. [email protected] wrote:

I have a customer that has a request that the select_datetime fields have
AM/PM selectors instead of 24 hour time.

Here’s a solution I whipped up for a project a while back. Might not
be the best solution, but it did the trick.

http://www.atlrug.org/atlrug/show/12HourHelper

-eric

Eric W. wrote:

On 6/8/06, Sean W. [email protected] wrote:

I have a customer that has a request that the select_datetime fields have
AM/PM selectors instead of 24 hour time.

Here’s a solution I whipped up for a project a while back. Might not
be the best solution, but it did the trick.

http://www.atlrug.org/atlrug/show/12HourHelper

Ahhh! Fantastic. And this is a lot better than i was expecting. Nice
solution to put it all into a single Drop. I thought about it being a
mess to have AM/PM selector on the side.

I’ve posted this link into my del.icio.us

I also made something similar, with an am/pm dropdown and model support:

http://www.happyfreelancer.com/?p=10

This is also supposed to be very good:

http://wiki.rubyonrails.org/rails/pages/FlexTimes+Plugin

Hope this helps!