0

My inserting format YYYY-MM-DDTHH:MM:SSZ, but this is incorrect. I want to treat YYYY-MM-DDTHH:MM:SSZ as YYYY-MM-DD HH:MM:SS, how to set my.cnf or other solution?

ActiveRecord::StatementInvalid:
   Mysql2::Error: Incorrect datetime value: '2013-06-14T10:07:43Z' for column 'created_at' at row 1: INSERT into `products` (`id`,`description`,`created_at`,`updated_at`) VALUES (1,'description','2013-06-14T10:07:43Z')

simular questions:

Community
  • 1
  • 1
Matt - sanemat
  • 5,418
  • 8
  • 37
  • 41

1 Answers1

1

You don't. You should never relax input restrictions. You can coerce the bad format into a valid one with something like

STR_TO_DATE('2013-06-14T10:07:43Z', '%Y-%m-%dT%k:%i:%sZ');
Marc B
  • 356,200
  • 43
  • 426
  • 500