I have a form where the user can input datetime and then I want to store it in the database. Here's my schema :
'start' => array( 'type' => 'varchar', 'mysql_type' => 'datetime', 'not null' => FALSE, ),
The form :
$form['add']['start'] = array( '#type' => 'datetime', '#default_value' => $date, );
When I hit submit button, it shows me :
db_insert failed. Message = SQLSTATE: Invalid datetime format: 1292 Incorrect datetime value:...
What I got out of it was that the DateTime in Drupal is incompatible with MySQL's. Any suggestions or how should I process the value from the form so I can insert it into the db?
Alternatively, any way to convert DrupalDatetime into string?
(For what it's worth I also tried 'timestamp' as the MySQL type but it throws me the same error).