mySQL 5.0 upgrade - incompatible DateTime format?


#1

I’ve upgraded to mySQL 5.0, and it’s gone pretty smoothly except that on
DateTime.now doesn’t seem to return a value that mySQL likes any more,
as seen in the following exception:

Incorrect datetime value: ‘2005-11-20T15:33:12-0800’ for column
‘logged_at’ at row 1: UPDATE notes SET due_on = ‘2005-11-20’,
created_at = ‘2005-11-20 15:33:12’, deleted = 0, user_name =
‘steve’, labels = NULL, job_name = NULL, domain_controller = NULL,
domain_id = NULL, contact_name = NULL, customer_id = NULL,
logged_at = ‘2005-11-20T15:33:12-0800’, user_id = 2, is_log = 0,
contact_id = NULL, vendor_id = NULL, job_id = NULL, subject =
‘test’, customer_name = NULL WHERE id = 8

what is that strange datetime value, anyway? the
one it’s trying to store looks like this:

‘2005-11-20T15:33:12-0800’

the DateTime that Rails generates automatically for updated_at looks
like this:

‘2005-11-20 15:33:12’

Does anyone know what’s going on here?
I’ve searched and have come up with zilch so far.


#2

that looks like a iso8601 date string. i think there were some problems
with
iso8601 formatted dates and mysql5…you’ll have to check the mysql
buglist
to be certain. in the meantime, you can do:

DateTime.now.strftime("%Y-%m-%d %H:%M:%S") # returns a string formatted
as
“2005-11-21 07:26:00”

or

Time.now.strftime("%Y-%m-%d %H:%M:%S")