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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:06:03+00:00 2026-05-25T16:06:03+00:00

User model has time_zone, which stores say Pacific Time (US & Canada). Scenario: 1.

  • 0

User model has time_zone, which stores say “Pacific Time (US & Canada)”.

Scenario:
1. Current_user lives in Japan timezone
2. Current_user is viewing profile of John who lives in “Pacific Time (US & Canada)”
3. On John’s profile, I need to show local time at “Pacific Time (US & Canada)” as 10:01 am

What I did?
ActiveSupport::TimeZone.new(@user.time_zone).now returns something like 2011-09-21 10:01:56 UTC

Questions:
1. How to do I convert this to 10:01 am?
2. Why is it UTC?

Please help

  • 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-25T16:06:03+00:00Added an answer on May 25, 2026 at 4:06 pm

    To set TimeZone, you need to use

    Time.zone= @user.time_zone
    

    You may want to set this in :before_filter in application.rb

    OTOH, you can use use_zone method with a block

    Time.use_zone(@user.time_zone) do
      #.... This code will run as if you were in @user.time_zone
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on a simple web app which has a user model and
Say I have a model called User that has the following parameters: favorite_color, favorite_animal,
in my app my user model has an instance_id which is related to the
in CI i created a model called User which has a method called entries
My user model has three relations for the same message model, and is using
I have a model that has a ForeignKey to the built-in user model in
My Rails 2.3 application has a User model and the usual controller actions. The
I have a User model and a Submission model. Each Submission has a ForeignKey
I have a model that holds user address. This model has to have first_name
We have a user model which :has_one detail . In a form_for a user,

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.