I have a column in my database called time
. the type of this column is timestamp
and Default value is CURRENT_TIMESTAMP
But after some inserts, in phpMyAdmin
it shows the value as datetime, e.g. 2019-05-05 04:24:45
and even the Timezone is shown there and can be changed!
I thought MySQL's timestamp is 4 bytes (compared to 8 bytes of datetime) and doesn't store timezone and data is same as INT(10) such as: 1557094115
(seconds passed since 1970 or something like that)
Can any one please explain this, is it a bug or something?
MySQL version 5.7.25
Edit 1 (Screenshots):
It is a TIMESTAMP
column, with default value of CURRENT_TIMESTAMP
As you see it is shown as DATETIME
and I cannot compare it with integer value of unix_timestamp... also we can change TimeZone to any value (I thought timestamp doesn't store timezone...)
Edit 2:
If (based on one answer) MySQL stores it as an integer internally, then why can't I compare it with integers? (the following query won't work)
DELETE FROM `table` WHERE time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL :days DAY))
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1555980012' for column 'time' at row 1
I also tried it in Sequel Pro and MySQLWorkbench with same results