I imagine this is a simple problem, however can''t seem to find the solution! In one of my mysql tables, I have a "time" field for storing elapsed time, HH:MM:SS. mysql> select * from rides; +----+-----------+------------+ | id | ride_time | ride_date | +----+-----------+------------+ | 1 | 00:37:44 | 2007-02-15 | +----+-----------+------------+ However when I get rails to list my rides, it does some funky business with the "ride_time" field, namely adding a date. Listing rides Ride time Ride date Sat Jan 01 00:37:44 EST 2000 2007-02-15 Show Edit Destroy How do I just print the time? Thanks, ajt. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ajtwatching wrote:> I imagine this is a simple problem, however can''t seem to find the > solution! > > In one of my mysql tables, I have a "time" field for storing elapsed > time, HH:MM:SS. > > mysql> select * from rides; > +----+-----------+------------+ > | id | ride_time | ride_date | > +----+-----------+------------+ > | 1 | 00:37:44 | 2007-02-15 | > +----+-----------+------------+ > > However when I get rails to list my rides, it does some funky business > with the "ride_time" field, namely adding a date. > > Listing rides > Ride time Ride date > Sat Jan 01 00:37:44 EST 2000 2007-02-15 Show Edit Destroy > > How do I just print the time? > > Thanks, > > ajt. > >I''m not sure if this helps your problem, but take a look at strftime: http://ruby-doc.org/core/classes/Time.html#M000255 Cheers, mohit. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I did a bit more research myself and stumbled upon this analysis.
http://substantiality.net/articles/2006/10/16/date-time-and-datetime-in-ruby
I''ve tweaked my list page with a bit of this action:
<%= ride.ride_time.strftime("%H:%M:%S") %>
and now it''s working as I''d expect!
ajt.
On Feb 15, 2:52 pm, "ajtwatching"
<ajtwatch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I imagine this is a simple problem, however can''t seem to find the
> solution!
>
> In one of my mysql tables, I have a "time" field for storing
elapsed
> time, HH:MM:SS.
>
> mysql> select * from rides;
> +----+-----------+------------+
> | id | ride_time | ride_date |
> +----+-----------+------------+
> | 1 | 00:37:44 | 2007-02-15 |
> +----+-----------+------------+
>
> However when I get rails to list my rides, it does some funky business
> with the "ride_time" field, namely adding a date.
>
> Listing rides
> Ride time Ride date
> Sat Jan 01 00:37:44 EST 2000 2007-02-15 Show Edit Destroy
>
> How do I just print the time?
>
> Thanks,
>
> ajt.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Sorry, missed your reply.. But thanks.. it was bang on! On Feb 15, 2:57 pm, Mohit Sindhwani <mo_m...-RxrYI66vbj0AvxtiuMwx3w@public.gmane.org> wrote:> ajtwatching wrote: > > I imagine this is a simple problem, however can''t seem to find the > > solution! > > > In one of my mysql tables, I have a "time" field for storing elapsed > > time, HH:MM:SS. > > > mysql> select * from rides; > > +----+-----------+------------+ > > | id | ride_time | ride_date | > > +----+-----------+------------+ > > | 1 | 00:37:44 | 2007-02-15 | > > +----+-----------+------------+ > > > However when I get rails to list my rides, it does some funky business > > with the "ride_time" field, namely adding a date. > > > Listing rides > > Ride time Ride date > > Sat Jan 01 00:37:44 EST 2000 2007-02-15 Show Edit Destroy > > > How do I just print the time? > > > Thanks, > > > ajt. > > I''m not sure if this helps your problem, but take a look at strftime:http://ruby-doc.org/core/classes/Time.html#M000255 > > Cheers, > mohit.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---