【发布时间】:2015-12-04 22:19:54
【问题描述】:
我正在编写一个简单的日历应用程序,但遇到了时区问题。对于许多不错的日期和时间助手,动作视图和活动记录肯定不适合时区。
我有一个约会模型,其约会时间属性是一个日期时间。
我当前的问题是在表单标签中使用 datetime_select 编辑约会时间。
<%= datetime_select :appointment_time, @appt.appt_time,ampm: true %>
def appt_time
appointment_time.in_time_zone(time_zone) #this is the appointment owners time zone
end
以 UTC 格式选择当前日期和时间,而不是约会日期和时间。 appt_time 确实被调用并返回为时区调整的正确日期和时间。
文档没有提到时区,实现它的最佳方法是什么?
【问题讨论】:
标签: datetime ruby-on-rails-4 timezone