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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:34:14+00:00 2026-05-24T19:34:14+00:00

I have some time defined from my database, and this is how it looks:

  • 0

I have some time defined from my database, and this is how it looks:

ruby-1.9.2-p290 :017 > djel.smjena.pocetak1.to_time 
 => 2000-01-01 08:00:00 +0100 

and that is ok, it assigned me 2000-1-1
also, I got something that happened in some datetime

ruby-1.9.2-p290 :019 > dog.pocetak 
 => Thu, 25 Aug 2011 08:18:00 UTC +00:00 

So I was hoping, that .to_time would ditch my date, but that does not
happen

ruby-1.9.2-p290 :020 > dog.pocetak.to_time 
 => Thu, 25 Aug 2011 08:18:00 UTC +00:00 

so, now, comparing if something happened before 8:00 is useless.
So, how can I compare that? is there a way to set dog.pocetak to
2000-01-01 without touch clock?

thank you

p.s. also, I thought of creating new time variable, only to get from old variable hours and minutes, but this methods dont work?

ruby-1.9.2-p290 :059 > dog.pocetak.hour
 => 8

but

ruby-1.9.2-p290 :060 > dog.pocetak.minute
NoMethodError: undefined method `minute' for 2011-08-25 08:18:00 UTC:Time
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/time_with_zone.rb:322:in `method_missing'
        from (irb):60
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start'
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start'
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
ruby-1.9.2-p290 :061 > dog.pocetak.minutes
NoMethodError: undefined method `minutes' for 2011-08-25 08:18:00 UTC:Time
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/time_with_zone.rb:322:in `method_missing'
        from (irb):61
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start'
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start'
        from /home/dorijan/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

really frustrating 🙂

  • 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-24T19:34:15+00:00Added an answer on May 24, 2026 at 7:34 pm

    With ActiveSupport and Time.change you can reset the year, month and day if you like:

    > t = Time.now
    => Sun Aug 21 00:46:29 +0000 2011
    > t.change(:month => 1, :day => 1, :year => 2000)
    => Sat Jan 01 00:46:29 +0000 2000
    

    This way you could compare the “times” between each other, if they all were reset to the same date. Not sure if this is a good solution though, depends on what you really are looking for.

    EDIT:

    As per mu’s suggestion you could also take a look at the time data type.

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

Sidebar

Related Questions

I have for some time build n-tier Applications using a database server as the
I have some trouble achieving adequate real-time performance from my application and wondering if
I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011
I have spent some time now to solve a problem for which i have
I have for some time tried to anthropomorphise (meaning human readable) the names I
Here is a question that I have had for some time but never actually
I have some unit tests that expects the 'current time' to be different than
I have already search for some time over the net on how to create
Quite some time i`ve learnt MVC. I have seen various techniques to post data
I have some custom logic that needs to be executed every single time a

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.