We can use the FROM_UNIXTIME() function to retrieve the value, as a MySQL TIMESTAMP, INT stored in a column of the table.
For example, we have a table named 'test123', which has a column named 'val1'. In this column, we store the integer value as follows -
mysql> Select * from test123; +------------+ | val1 | +------------+ | 150862 | | 1508622563 | | 622556879 | | 2147483647 | +------------+ 4 rows in set (0.00 sec)
Now with the help of FROM_UNIXTIME() function, we can retrieve the column integer value in the form of MySQL TIMESTAMP data.
mysql> Select FROM_UNIXTIME(Val1) from test123; +---------------------+ | FROM_UNIXTIME(Val1) | +---------------------+ | 1970-01-02 23:24:22 | | 2017-10-22 03:19:23 | | 1989-09-23 17:57:59 | | 2038-01-19 08:44:07 | +---------------------+ 4 rows in set (0.00 sec)
The above is the detailed content of What is the correct way to retrieve a value stored in an INT column as a MySQL TIMESTAMP?. For more information, please follow other related articles on the PHP Chinese website!