0
我顯示來自PostgreSQL數據庫的事件,我的時間戳顯示爲,如果他們要在四個小時內發生..我的時間戳來自未來?
在我的數據庫使用select * from event
顯示正確的時間戳。爲什麼rails會顯示與數據庫中不同的時間戳?
我想只顯示數據庫中的時間戳。
控制器代碼:
ips_timestamp = event.timestamp.to_s(format = :db)
@ips_events += [timestamp: ips_timestamp]
查看代碼:
<% @ips_events.each do |event| %>
<%= event[:timestamp] %>
你可能有timestamp'和'timestamptz'的'組合。詳細信息:http://stackoverflow.com/questions/9571392/ignoring-timezones-altogether-in-rails-and-postgresql/9576170#9576170 –
我也願意打賭它與時區有關... – sethvargo
我的時區是默認的UTC。這只是在'application.rb'中改變了嗎? –