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

  • SEARCH
  • Home
  • 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 223251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:12:13+00:00 2026-05-11T19:12:13+00:00

I have a rails application and I store all time in UTC in the

  • 0

I have a rails application and I store all time in UTC in the database for TimeZone differences’ purposes. I also expire a record instead of deleting it by setting “effective_end_date” field in the table to current time. Then I use named scope as follows in the model:

  named_scope :valid, :conditions => ['(effective_end_date IS NULL OR effective_end_date > ?) 
                                 AND (effective_start_date IS NULL OR effective_start_date < ?) ',Time.zone.now.gmtime, Time.zone.now.gmtime]

This seems to work fine on my Mac dev machine but once I move to production there seems to be discrepancy between the system time and the time which I’m not sure why!! Typing “date” command in Linux seems to give the right time. Looking at the production log file below:

sms parser(inparser) daemon is still running at Wed Jun 03 22:38:36 -0700 2009.
[4;35;1mUltrasmsin Load (0.5ms)ESC[0m   ESC[0mSELECT * FROM `smsin` WHERE ((effective_end_date IS NULL OR effective_end_date > '2009-06-04 05:28:32') 
 AND (effective_start_date IS NULL OR effective_start_date < '2009-06-04 05:28:32') ) 

This the generated query from the following lines of code:

ActiveRecord::Base.logger.info "sms parser(inparser) daemon is still running at #{Time.now}.\n"
nonConvertedMsgs = Ultrasmsin.valid.find(:all)

The first command time displayed from “Time.now” is correct but the second time (fetched from the named scope) seems to be wrong!! (off by 10 minutes)

This is really puzzling me as I would think Time.zone.now.gmtime would just convert hours and wouldn’t touch the minutes but it seems that hours are converted ok to GM Time but the minutes are off by 10 minutes!

Any ideas?

  • 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-05-11T19:12:13+00:00Added an answer on May 11, 2026 at 7:12 pm

    On your Mac development machine, everything – DBMS, Rails, browser – is probably running in a single time zone, and it is your time zone.

    On your production machine, it is likely that something is running in a different time zone. How a DBMS handles differences between client time zone and the database time zone varies, depending on the DBMS. Some operate in the DBMS’s time zone – whatever time zone was set in its environment when it was started. Some take into account the client’s time zone. Sometimes, there is no easy way to find the client’s time zone.

    In general, time zones in the modern world are multiples of 1 hour off UTC. There are exceptions – both India (+05:30) and Newfoundland (-04:30) are a multiple of half an hour off UTC, and Nepal is on (+05:45). However, a malformed time zone setting could throw things off.

    Also remember that the clocks on the client and server may not be synchronized to an atomic clock somewhere, so a ten minute drift could be due to the lack of SNTP (NTP) service on the machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails application, running in development mode ( with a sqlite database
I have written an application for an online clothing store in Rails 2.3.5. I
I have a ruby on rails 3.0 application which will need a database containing
I have a rails application linked to a database table, which contains e-mail addresses
In my Rails application I have a simple controller which also has an action
In my Rails application I have a separate process (BackgroundRb) to delete all transactions
In my rails application, I have a controller called demo which is stored at
I have Rails application with mounted Engine. #{main_app}/config/routes.rb mount CommentIt::Engine => /talk, :as =>
I have rails application running in linode server .Some guy is continuously spamming (writing
I have a Rails application that accepts file uploads of CSV files. When developing

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.