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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:05:50+00:00 2026-05-21T16:05:50+00:00

I have some strange behavior in my rails3 app. When I pick a date

  • 0

I have some strange behavior in my rails3 app.

When I pick a date with jquery UI datepicker. I see this in my log

Parameters: {"commit"=>"Save", "log"=> {"log_date"=>"04/20/2011"} ....blah...b}
AREL (1.0ms)  INSERT INTO "logs" ("log_date") VALUES ('2011-04-19 22:00:00.000000')

I’ve left out the irrelevant information.

As you see Rails does not translate the date inputted correct. It changes (in this case) 20.apr to the 19.apr.

When I later call

<%= log.log_date.strftime('%d.%m.%y') %> 

I get the corect date, but when I do this query

@log_times = Log.group(:log_date)

The logs are all one day earlier than they sould be.

In the console the log in this example looks like this

irb(main):017:0> Log.last
=> [#<Log id: 246,  log_date: "2011-04-19 22:00:00">]

So, its save one date to early, but when I show it in the view it’s correct.

Why?

Could I use a getter and setter to fix this?

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

    Rails is built to handle timezones by default. Times stored in the database are stored in UTC and Rails is supposed to handle translating that into the configured local time automatically.

    Do you have config.time_zone set in your application.rb file? Also, I’d recommend using DateTime rather than Time when possible.

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

Sidebar

Related Questions

I have some strange behavior in my iphone app. I have an NSTimer which
I have come across some strange behavior in my iPhone Objective-C app. I am
I've experienced rather strange behavior of JSTL forEach tag. I have some bean called
I have some code like this in a winforms app I was writing to
Something really weird is happening to my Rails app. For some strange reason, jQuery
Having some strange behavior here. I have some XSLT which generates some html with
I have experienced some strange behavior of Objective-C++. I have an Objective-C++ class, and
I have encountered some strange Perl behavior: using a Posix character class in a
I am experiencing some strange behavior with SQL Server CE 3.5 SP2. I have
facing some strange behavior in OSB, i have configured WLS with MQ in client

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.