Parsing Dates bewilderment

Ok, so to me this seems like a very trivial issue, but it is causing
hours
of frustration.
I am hoping that an extra thousand or so sets of eyes will point out
where I
am obviously making a newbie mistake.

I have the following string:

“08-04-2006” representing August 4, 2006

I set my attribute ‘po_date’ equal to this string and then save it to
the
database.
My ‘po_date’ is in a MySQL database with a column type of ‘datetime’.
When the record is saved to the database, the value is saved as:

"2006-04-08" representing April 8, 2006

Is there something I am missing in the accepted formats of strings when
saving a record to the database?
Also, when I attempt to pass the string:

 "08-04.2006"

into the DateTime.parse() method I get “invalid date”.
And when I pass the same string into the Time.parse() method I get
“argument
invalid” error.

Any help in the right direction here would be greatly appreciated and I
sit
back and await the chastisement of such a trivial problem :frowning:

Thanks,

Hi Damon,

I found Jonathan V.'s plugin useful for parsing and validating
dates and times:
http://svn.viney.net.nz/things/rails/plugins/validates_date_time/

See the readme re: options for ordering day/month/year. Hope this helps.

Dan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs