Time_select form helper interprets the new time object as UTC not as a configured time zone

I come across what seems like a simple problem to me, but I can’t understand what I am doing wrong. In my application, users can add their course through a simple form_for. They can enter start_time and end_time for course lectures, for example:

<div class="field">
  Start Time<br />
  <%= time_select :course, :start_time, { :minute_step => 5, :ampm => true } %>
</div>

<div class="field">
  End Time<br />
  <%= time_select :course, :end_time, { :minute_step => 5, :ampm => true } %>
</div>

I set my timezone in the .rb application for installation in Eastern time, and this seems to work correctly since created_at is returning to the correct timezone.

However, the problem I am facing is that start_time and end_time are entered as UTC in the database. Therefore, when a user selects a class starting at 10:00, it is entered as 10 UTC, not 10 AM EST / 15: 00 UTC. What am I missing here? It seems like I want this to happen.

+5
source share
2 answers

To summarize the answer from the comments, to remove this question from the "No Answer" filter:

Suggested Tim Brandes :

Perhaps this will help you: Time zone with rails 3 ... I never used time_select, but always datetime_select when working with time zones, maybe this can be a problem, but it seems unlikely.

, Philip V:

start_time end_time , UTC.... start_time end_time datetime, , . , UTC.

+2

. , Time.

, UTC, , :

course.start_time.hour
course.start_time.min

. (8 - 8 , , . 30 - 30 0 . , ).

, , , , , UTC , .

0

All Articles