Mario Trento wrote in post #1050601:
Thanks, all
I have this value as string "4:57PM", and I have a function now, but
want to do it in simpler way: 4:57AM --> 16:57. This needed only for
"PM" time
t = Time.parse("4:57PM")
=> Thu Mar 15 16:57:00 +0000 2012
t.strftime("%H%M")
=> "1657"
But you're actually doing more work than needed, because it's working
out the number of seconds since midnight on Jan 1st 1970 for that
particular time *today*
t.to_i
=> 1331830620
... and then converting back to local time and then just extracting the
hours and minutes.
ยทยทยท
--
Posted via http://www.ruby-forum.com/\.