What is the difference between DATETIME and TIMESTAMP?

PointDATETIMETIMESTAMP
Range1000-01-01 to 9999-12-311970-01-01 to 2038-01-19
Time zoneStored as it isConverted to UTC and back to the session time zone
Auto updatePossible with a defaultCommon for created_at and updated_at
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

See MySQL Data Types and Date Functions.


Learn more about the similar topics:
Tutorials
MySQL Data Types
MySQL CREATE DATABASE
MySQL USE and SHOW DATABASES
MySQL DROP DATABASE
MySQL CREATE TABLE
MySQL Constraints
MySQL DROP TABLE
Exercises & Assignments
Write a query to get all column names of a database table
Write a query to create a new table with the data and structure of another table
Interview Questions & Answers
Write a query to create a new table which consists of data and structure copied from the other table
What is a primary key in MySQL?
What is a foreign key in MySQL?
What is the difference between CHAR and VARCHAR in MySQL?
What is normalization in MySQL?
What is AUTO_INCREMENT in MySQL?
What is the difference between primary key and unique key?