mysql – Difference between datetime x timestamp?

Question:

I'm building a diagram in MySQL Workbench and this question came up, what's the difference between the two?

I'm going to work with this base in Java, does java have a problem with any of them?

Answer:

The biggest difference between datetime and timestamp is the following:

  • datetime : represents a date as in the calendar and the time as found in the clock.
  • timestamp : represents a specific point on the timeline and takes into account the time zone in question ( UTC ). For example: when was it 26/02/2015 16:40 ? it depends, for me it's right now, for Japan it was several hours ago, so basically the timestamp takes into account these time zone issues.

Another point is that, generally, when you need to track changes made to database records, you choose to use the timestamp because it allows you to drill down to the real-time line.

Scroll to Top