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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:02:46+00:00 2026-06-14T04:02:46+00:00

I thought the Time object in Ruby on Rails stores the time but when

  • 0

I thought the Time object in Ruby on Rails stores the time but when I ran Time.now.beginning_of_day it gives me the date as well. I’m just trying to capture the time and not the date at all. Is there a 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-06-14T04:02:48+00:00Added an answer on June 14, 2026 at 4:02 am

    Yes you have to do Rails Date Formats – strftime

    please see this kink http://www.wetware.co.nz/2009/07/rails-date-formats-strftime/

    and this link http://apidock.com/ruby/DateTime/strftime

    Example:
    // in your case, should do it
    Time.now.beginning_of_day.strftime(“%I:%M”)

    With preceding zero (capital I)
    
    Time.now.strftime("%I:%M") # => 05:21
    Without preceding zero (lowercase L)
    
    Time.now.strftime("%l:%M") # => 5:21
    

    hope it help.

    UPDATE: // well for your question on the comment below Why is Time storing date information? Shouldn't it just be time?

    Good point for you question, as vladr mention it above(I am sure that the group of people who create rails will think very similar to vladr mention above when they gonna design Time object in rail), when you are talking about time, it cannot be help that it will related to the time zone too. In your case you want to use Time.now.beginning_of_day right? I am now in Thailand and assume that you are in America, Time in America is slower than Thailand for 12 hours, so right now in Thailand it’s Tue 10:00 am, then in America should be Mon 10:00 pm, so you use Time.now.beginning_of_day (let use Time.now for more clear picture), so what should be the answer? so that’s why I think the group of people who create rails use UTC+0 as a standard, In your case I recommend using Time.zone.now, and recently I have found some blog with interesting topic, please see http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails, hope it help. anyone who read this if you feel that something is missing, feel free to edit my answer, thank you very much for you guys :).

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

Sidebar

Related Questions

I'm trying to create a simple date class, but I get an error on
Using IRB, why are the Date & Time classes automatically loaded, but DateTime is
I have a Joda Date Time object that contains date and time fields and
I've ran into a strange bug in Ruby on Rails. I'm attempting to implement
I have been asking myself this question for a long time now. Thought of
I thought every time you do a flash[:notice]=Message it would add it to the
After a couple of weeks reading on this forum I thought it was time
I removed, what at the time I thought, was an unnecessary field/column from a
I thought I'd be flexible this time around and let the users decide what
Once upon a time I was thought by more advanced web developers (gee, when

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.