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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:10:35+00:00 2026-05-22T18:10:35+00:00

I use rails for version 2.3.5, when i update or save a record, the

  • 0

I use rails for version 2.3.5, when i update or save a record, the created_at and updated_at fields can be filled in automatically in the format like ‘2011-05-17 23:54:53’, however i want to store the second int value of time to these fields automatically, what should i do?

Thank you in advance.

  • 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-22T18:10:35+00:00Added an answer on May 22, 2026 at 6:10 pm

    Within your database engine the storage method for dates, times, datetimes, and timestamps can vary but the presentation through the SQL layer is often similar. You can transform the request from integer to time if you like using some of the built in functions.

    For example, in MySQL you can use the UNIX_TIMESTAMP function to return integer times:

    SELECT UNIX_TIMESTAMP(created_at) FROM users
    

    You can also insert integers and convert to times:

    UPDATE users SET updated_at=FROM_UNIXTIME(1111885200) WHERE id=1
    

    This sort of thing is not supported natively within ActiveRecord, but you can do conversions using the DateTime class:

    User.first.created_at.to_i
    

    You can also convert from an integer to a DateTime:

    user.updated_at = Time.at(1111885200)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the last version of rails, in my Gemfile: gem 'rails',
Short and sweet, Is it ok to use (current version) Ruby 1.9.1 with Rails
I'd like to use Rails 2.2.2 for one project and Rails 2.3.2 for another.
In models and controllers, we often use Rails macros like before_validation , skip_before_filter on
How can I use rack 1.3.0 with rails. I tried putting gem 'rack', '1.3.0'
I'm use Rails 2.2.2. Rails manual said, the way to extend controller from plug-in
Is it architecturally sound to use Rails and Oracle? My concern is that Oracle
when starting Ruby on Rails programming, I will use rails first rails second and
I'm building an app to store files on my s3 account. I use Rails
I use the rails 3.0.0.beta Is there any new syntax to write RJS, here

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.