0

I'm displaying events from a PostgreSQL database, and my timestamps show as if they are going to happen in four hours..

Using select * from event in my database shows the correct timestamp. Why is rails displaying a different timestamp than what is in the database?

I would like to just show the timestamp as it is in the database.

Controller code:

ips_timestamp = event.timestamp.to_s(format = :db)

@ips_events += [timestamp: ips_timestamp]

View code:

<% @ips_events.each do |event| %>
<%= event[:timestamp] %>
insecure-IT
  • 2,068
  • 4
  • 18
  • 26

1 Answers1

0

You probably have a mix of the data types timestamp and timestamptz. Like saving a timestamp with time zone (timestamptz), but later displaying a timestamp without timezone (timestamp) or vice versa.

Details in this related answer:
Ignoring timezones altogether in Rails and PostgreSQL

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228