Skip to main content

Posts

Showing posts with the label TIMESTAMP

MySQL –TIMESTAMP or DATETIME difference

MySQL - When to Use TIMESTAMP or DATETIME - Difference Between TIMESTAMP or DATETIME clocktimeimage This is a one of the most popular question, I often receive when MySQL Developers are creating a database. There are multiple datatypes which can store DateTime datatype in MySQL. Range The supported range for DATETIME type is ‘ 1000-01-01 00:00:00 ’ to ‘ 9999-12-31 23:59:59 ’. The supported range for TIMESTAMP type is ‘ 1970-01-01 00:00:01 ’ UTC to ‘ 2038-01-19 03:14:07 ’ UTC . That means if you want to store date which is before the year 1970 or after the year 2038 you will need to use DATETIME . Conversion As per the MySQL official documentation – MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. This means, if your application is such where you want time to stay absolutely steady with respect to GMT, you must use TIMESTAMP, or else you should use it with DATETIME. For example, if I am...