Time_select with 12 hour time and time zone in Ruby on Rails

I need to fix the time and time zone for users of the rails 2.3.8 application, but could not come up with a clean solution for creating and analyzing options.

Ideally, I have a drop-down menu for the following:

  • hour (1-12)
  • minute (0-59)
  • AM / PM
  • Timezone

Is there a gem / plugin that does what I'm looking for? Do I need to store both time and timezone in a database? What is the best storage strategy?

In the end, I will have to spit out these values ​​in UTC, but the user should be able to return and view the time in the correct time zone.

+5
source share
2

:

, date_select .

:

, current_user. Rails / UTC UTC ( !). .

use_zone () , .

UPDATE: Rails .

+11

jQuery :

 ampm = ["12 AM","01 AM","02 AM","03 AM","04 AM","05 AM","06 AM","07 AM","08 AM","09 AM","10 AM","11 AM","12 PM","01 PM","12 PM","01 PM","02 PM","01 PM","02 PM","03 PM","04 PM","05 PM","06 PM","07 PM","08 PM","09 PM","10 PM","11 PM"]
    j("#game_start_time_4i option").each(function(index,value){
        j(value).html(ampm[index]);
    });

:

<%= datetime_select('game', 'start_time') %>
+1

All Articles