0

I created a column (created_at) to store a timestamp, but I am confused whether I should use int, bigint or timestamp data type to store the timestamp.

Please clarify it in detail.

Mike
  • 23,542
  • 14
  • 76
  • 87
Trliok
  • 361
  • 1
  • 17
  • 1
    possible duplicate of [datetime vs timestamp?](http://stackoverflow.com/questions/409286/datetime-vs-timestamp) – Mike Sep 07 '15 at 06:06
  • obviously you have to use the "timestamp" data type store timestamp data – Arun Sep 07 '15 at 06:07
  • @arun--> I saw that int is used to store timestamp. http://fuelphp.com/forums/discussion/6027/why-use-int-instead-of-datetime-or-timestamp-in-the-039users039-table – Trliok Sep 07 '15 at 06:15

1 Answers1

0

You must use TIMESTAMP because:

In Timestamp values are converted from the current time zone to UTC while storing, and converted back from UTC to the current time zone when retrieved.

And for more detail refer this: http://www.w3resource.com/mysql/mysql-data-types.php

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
  • but i think it would be create problem after 2038. https://en.wikipedia.org/wiki/Year_2038_problem – Trliok Sep 07 '15 at 06:22
  • @Trliok That problem only exists on 32 bit systems, which, are practically nonexistent for any computers made in the last 2-3 years. By the time 2038 comes around (and even way before that) it's very unlikely anything would still be using 32 bit processors. I would assume it would be like trying to find a 16 bit processor today, which were once the standard back in the mid-90's. – Mike Sep 07 '15 at 06:26
  • @mike--according to you which datatype is best? – Trliok Sep 07 '15 at 06:58