Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:47:27+00:00 2026-06-17T16:47:27+00:00

Steps: On my localhost server I select the time Jan 18, 2013 10 am

  • 0

Steps:

On my localhost server I select the time Jan 18, 2013 10 am – 11 am in my browser located in the Pacific time zone. I then select the exact same time on my production server on heroku.

As you can see the outputs of what is saved to the database are different. I want production to behave as localhost and take into account the timezone when storing the time as UTC. What is causing this? The heroku server is in EST, but that does not account for this behavior.

Controller:

  def create
    puts params[:event][:starts_at]
    @event = Event.create!(params[:event])
    puts @event.starts_at
  end

Output Localhost:

Fri Jan 18 2013 10:00:00 GMT-0800 (PST)

2013-01-18 18:00:00 UTC

Output Heroku (production):

Fri Jan 18 2013 10:00:00 GMT-0800 (PST)

2013-01-18 10:00:00 UTC

Schema:

 t.datetime "starts_at"

Env:

Ruby on Rails 3.2.11

Ruby 1.9.3

Postgres

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:47:28+00:00Added an answer on June 17, 2026 at 4:47 pm

    Background on how PostgreSQL deals with date/time

    I think your issue is covered in this answer from another SO question:

    • Ignoring timezones altogether in Rails and PostgreSQL

    Specifically this answer:

    • https://stackoverflow.com/a/9576170/33204

    Use this query for time in UTC format:

    SELECT * FROM tbl WHERE time_col > (now() AT TIME ZONE 'UTC')::time
    

    Use this query for time in local timezone:

    SELECT * FROM tbl WHERE time_col > now()::time
    

    Rails & ActiveRecords & date/time

    This rails/rails github issue also discusses it:

    • ActiveRecord converts time to default zone on write; assumes UTC on read

    There is a comment by pixeltrix which says the following:

    @deathbob sorry for the late reply – the accepted values for
    config.active_record.default_timezone are either :utc or :local. If
    you set it to something other than :utc it will assume :local so what
    you’re seeing is the expected behavior.

    To fix the time in ActiveRecords so that it is always dealt with as UTC you can set the following variable:

    config.active_record.default_timezone = :utc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've followed the exact same steps which have always previously worked for me, create
I am trying to create an exact mirror of a Magento production server on
I have followed a link http://lukesampson.com/post/315838839/cas-on-windows-localhost-setup-in-5-mins , then the cas server works correctly, the
What steps will reproduce the problem? Create a MenuBar object (createMenuBar) Create a Server
I have written a app in PHP on my localhost server using XAMP, which
if I open my SVN http://localhost/repos/XXX The browser says : Forbidden You don't have
I've set up my subversion server following the steps on : http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html The server
Steps: 1. sudo port boost The boost file installed in /opt/local/boost, library files are
Steps: Run the build including unit tests. Expected result: the unit tests are executed
The steps i took exactly on the terminal went to the project directory i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.