Is there a way to insert "0000-00-00 00:00:00" datetime database field?
Should I change the database field's default value to "0000-00-00 00:00:00"?
I got replies on Stack Overflow, and it works with plain PHP, but it gives an error with Drupal.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
In Drupal 7 DB API, support for the
datetime type was removed. This means that you must use use
pgsql_type if you want this functionality. Below is an example of of to declare this schema provided your database is MySQL. By setting
not null to
FALSE, you can store an empty value (
''), which is equivelent to
'mydate_date' => array( 'description' => t('My date field.'), 'type' => 'varchar', 'mysql_type' => 'datetime', 'not null' => FALSE, ),
Note that to make the schema portable, you should provide a fallback type (
varchar) for the case that the database is not mySQL.