Forum: Ruby on Rails AM/PM select

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.
8f15d89f469605e9e07a8b5ce5d3d5d1?d=identicon&s=25 Sean Wolfe (Guest)
on 2006-06-08 10:07
(Received via mailing list)
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 Wolfe
master nerd of
i heart squares, inc.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
http://www.iheartsquares.com
4a021d3e4528fb8ab78ef7fc4b6822cc?d=identicon&s=25 Bao Lee (burninglegion)
on 2006-06-08 11:03
Sean Wolfe 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 Wolfe
> 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!
2b404bb55d9b5dc78841795c4b731771?d=identicon&s=25 Damien (Guest)
on 2006-06-08 12:44
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..
0f1fa6b6ea69391ae1d1f64b33cb77b8?d=identicon&s=25 Eric Wagoner (Guest)
on 2006-06-08 13:43
(Received via mailing list)
On 6/8/06, Sean Wolfe <sean@iheartsquares.com> 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
8f15d89f469605e9e07a8b5ce5d3d5d1?d=identicon&s=25 Sean Wolfe (Guest)
on 2006-06-08 22:35
Eric Wagoner wrote:
> On 6/8/06, Sean Wolfe <sean@iheartsquares.com> 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
43ec5998360a0cc21b51afef1781e9c0?d=identicon&s=25 Daniel Higginbotham (danieldaniel)
on 2006-06-08 22:44
(Received via mailing list)
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!
This topic is locked and can not be replied to.