I use drupal and the pgsql database, but after a long search I still can’t figure out how to put CURRENT_TIMESTAMP or now () in the database when inserting a row into the table. Putting now () by default for the column will not work, because drupal will not accept it in the database schema, so this is out of the question.
The current column type is the “timestamp without timezone” or “time without timezone” that the drupal schema accepts. Now the problem is that the date is added there.
I tried:
$now = format_date(time(), 'custom', 'Y-m-d H:i:s');
and pasting it with the string placeholder '% s', but pgsql gave me an error.
I also tried changing the type to an integer and pasting it using the time () php function, and it didn’t work (if I used it on other tables), maybe I will stick to the timestamp as it makes sense.
source
share