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

The Archive Base Latest Questions

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

I have the following entry in my database: t.time :my_time_stamp In my controller I

  • 0

I have the following entry in my database:

t.time :my_time_stamp

In my controller I update it like this:

model.update_attributes(:my_time_stamp => Time.now.utc)

I can see that I’m writing:

Mon 9 November, 8:54.54 UTC 2009 

However, when I later read this value I get:

Sat Jan 01 08:54:54 UTC 2000

It seems that the time part has been stored but not the date part. I’d expect that because it’s a time field, but why do I end up storing and retrieving a date? I guess I must be misunderstanding how this works in some fundamental way…. what am I doing wrong?

What I need to do is calculate the time in seconds since the update to the database…. is there an easier way to do this?

Thanks!

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

    Ruby does not have a dateless time object, so it converts the dateless time field in your database to that time on some arbitrary day. Ruby’s Time objects encode a number of seconds since the unix epoch, so they include the date. The correct way to store them in the database is with a datetime field, or if you prefer, you could use an integer field and store Time.now.to_i.

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

Sidebar

Related Questions

In my database, I have the following entry id | name | info 1
In our database we have a user. A user can have certain metadata (Like
During testing I have failed to notice an incorrect date/time entry into the database
I'm using Spring and struts and have the following entry in '/META-INF/context.xml' <Context cachingAllowed=false
I have the following log entry that I am processing in PowerShell I'm trying
I have been following the validation for Entry boxes from here . The code
I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
I have the following XML Document: <?xml version=\1.0\ encoding=\UTF-8\?> <atom:entry xmlns:atom=\http://www.w3.org/2005/Atom\ xmlns:apps=\http://schemas.google.com/apps/2006\ xmlns:gd=\http://schemas.google.com/g/2005\> <apps:property
I have a simple table like following: class SnookerCurrentInfo extends Doctrine_Record { public function

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.