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 50763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:38:39+00:00 2026-05-10T16:38:39+00:00

I am working on a Rails application that needs to handle dates and times

  • 0

I am working on a Rails application that needs to handle dates and times in users’ time zones. We have recently migrated it to Rails 2.1 and added time zone support, but there are numerous situations in which we use Time#utc and then compare against that time. Wouldn’t that be the same as comparing against the original Time object?

When is it appropriate to use Time#utc in Rails 2.1? When is it inappropriate?

  • 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. 2026-05-10T16:38:40+00:00Added an answer on May 10, 2026 at 4:38 pm

    If you’ve set:

    config.time_zone = 'UTC' 

    In your environment.rb (it’s there by default), then times will automagically get converted into UTC when ActiveRecord stores them.

    Then if you set Time.zone (in a before_filter on application.rb is the usual place) to the user’s Time Zone, all the times will be automagically converted into the user’s timezone from the utc storage.

    Just be careful with Time.now.

    Also see:

    http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/

    http://errtheblog.com/posts/49-a-zoned-defense – you can use the JS here to detect zones

    Hope that helps.

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

Sidebar

Related Questions

I'm working on a Rails application that's kind of like a blog. Users create
I am working on a rails application (I have some experience with rails). But,
I have a Rails 2.3 web application that uses the collection_select helper with :multiple
Im working on a Rails based application where I have the need to allow
I have been building a Rails application that performs accounting functionality. As part of
I am currently working on rails3 application that uses jQuery. I have a javascript
I am working with Rails fixtures for testing my rails application. It is all
I'm trying to get tags working in my rails application and want to use
I'm working on a Rails web application, and it's currently being used by some
I am working on the billing component of a Ruby on Rails application using

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.