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

Related Questions

I have a form element that contains multiple lines of inputs. Think of each
I have asp.net form that contains fields. When I access this window, my javascript
I have a form that contains a GridView control which is databound to an
I have a form that contains a bunch of checkboxes. Before submitting the form,
I have an asp.net text form that contains numerous decimal fields that are optional.
I have a form that has a few similar controls and the parent contains
I would like to have an aspx page that contains something like.... <form id=form1
I have a field in my form labeled Name that will contain both the
I have two functions to add and remove table rows that contain a form
I have form that displays several keywords (standard set of choice lists that changes

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.