I would like to be able to parse date fields from a MySQL database in order
to get the day, year, hour etc. separately. Which library could do that for
me? I can't think that I would have to parse those dates myself, right?
Bart
I would like to be able to parse date fields from a MySQL database in order
to get the day, year, hour etc. separately. Which library could do that for
me? I can't think that I would have to parse those dates myself, right?
Bart
I would like to be able to parse date fields from a MySQL database in order
to get the day, year, hour etc. separately. Which library could do that for
me? I can't think that I would have to parse those dates myself, right?
Just use Date#day, Date#year, Date#hour and so on.
Il giorno 08/nov/06, alle ore 16:25, Bart Braem ha scritto:
Bart
--
Gabriele Marrone
require 'time'
parsed_time = Time.parse(mysql_datetime)
If the mysql field has a value that is outside the range for Ruby's Time class, you can use DateTime:
require 'date'
parsed_time = DateTime.parse(mysql_datetime)
Kirk Haines
On Thu, 9 Nov 2006, Bart Braem wrote:
I would like to be able to parse date fields from a MySQL database in order
to get the day, year, hour etc. separately. Which library could do that for
me? I can't think that I would have to parse those dates myself, right?
khaines@enigo.com wrote:
parsed_time = DateTime.parse(mysql_datetime)
Combined with the methods from Gabriele this works perfectly, thanks!
Bart
parsed_time = DateTime.parse(mysql_datetime)
Combined with the methods from Gabriele this works perfectly, thanks!
Oops! Sorry, I thought you were using ActiveRecord, so it was already parsed
Give it a look, of course you can use it outside Rails, if you need it: http://rubyonrails.org/api/classes/ActiveRecord/Base.html
On 08/nov/06, at 20:30, Bart Braem wrote:
khaines@enigo.com wrote:
Bart
--
Gabriele Marrone