-1

For my module I want to create a table with an updated_on and created_on field, both of type timestamp.

I found this can be done with mysql_type, but you need to specify a default value for that column or it won't work. So I'm using CURRENT_TIMESTAMP.

However, you cannot use CURRENT_TIMESTAMP for both columns as explained here and Drupal by default does not seem to accept zero date fields, as discussed here.

Is is somehow possible to create a table using hook_schema with two timestamp fields without touching Drupal core? I'm using Drupal 7.

I know Drupal uses unix timestamps for dates, but it feels more natural to me to use the MySQL timestamp field and work with that (although Drupal seems to think otherwise)

1 Answer 1

0

I searched around and don't think this is currently possible. In the end I reverted to using the unix timestamps that Drupal by default uses anyway. Instead of the current timestamp, I now just add REQUEST TIME to the db statements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.