4

I want to make this question short, so as title says "Why all dates in drupal are INT" ?

I've notice that in Schema API there was "datetime" but it was removed in D7. Also all tables that have time in it (cache_*,semaphore,node etc.) have INT instead of TIMESTAMP.

Before debating "INT vs TIMESTAMP" flame, I would like to remind you that:

  • DATETIME is obvious what the value represents.
  • INT is smaller
  • TIMESTAMP has both advantages.

The thing is that I want to understand what's "philosophy of drupal" for this.

  • 2
    Because Drupal doesn't just support MySQL as a backend, it also supports backends that do not have a DATETIME/TIMESTAMP type. If it's a problem see the docs and use one of the db specific types (e.g. mysql_type) for your schema – Clive Sep 24 '12 at 8:48
  • drupal supports postgres and sqlite. Both have DATETIME... – confiq Sep 24 '12 at 8:57
  • 2
    Then I would guess their implementations are not uniform across the different DBMSs, and so can't be used generically – Clive Sep 24 '12 at 8:58
  • well that's my guess too... Just wanted to be sure! – confiq Sep 24 '12 at 10:16
2

I guess the main reason its that you cannot have two columns with TIMESTAMP and default NOW() value in MySQL according the documentation (see that answer). So seems to be the easier way to workaround it its to use int.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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