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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:56:10+00:00 2026-05-11T12:56:10+00:00

I have a form that contains one date element and 3 time elements. This

  • 0

I have a form that contains one date element and 3 time elements. This is because 3 time events will occur on one date, and I don’t want the user to have to input that date 3 times.

On the server side, I would like to combine the one date with the 3 times to get 3 datetime objects. I was thinking I could just do something like:

time_object.change(:day => date_object.day, :month => date_object.month, :year => date_object.year) 

but this has not worked. Here is a simple test I have written that I would expect to work:

  def before_validation     logger.info('show_time = ' + self.show_time.to_s)     self.show_time.change(:year => 2012)     self.show_time.change(:minute => 30)     logger.info('show_time = ' + self.show_time.to_s)   end 

The two print statements should be different, but they are the same. Does anyone know the best way to merge a Time and Date object?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T12:56:11+00:00Added an answer on May 11, 2026 at 12:56 pm

    You need to assign it. If you go into script/console:

    >> t = Time.now => Thu Apr 09 21:03:25 +1000 2009 >> t.change(:year => 2012) => Mon Apr 09 21:03:25 +1000 2012 >> t => Thu Apr 09 21:03:25 +1000 2009 >> t = t.change(:year => 2012) => Mon Apr 09 21:03:25 +1000 2012 >> t => Mon Apr 09 21:03:25 +1000 2012 

    so maybe:

    self.show_time = self.show_time.change(:year => 2012) 

    could work for you. I don’t know how I feel about that solution, but it should work.

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

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm going to go with "neither" here, and tell you… May 12, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer You can use the not selector to prevent one (or… May 12, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer You can always use: overflow: hidden; To hide the scrollbars. May 12, 2026 at 11:59 am

Related Questions

How do I attach an onclick event to a link_to_function such that clicking on
A UI question: is there some consensus on the best (defined as the one
I have a tabbed html form. Upon navigating from one tab to the other,
I have a python script that, once executed from command line, performs the needed

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.