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.
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.
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.
> 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.
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.
Sorry, missed your reply..
But thanks.. it was bang on!