如何将 MySQL 表中存储的 epoch 转换成可读日期?
为了说明这一点,我们使用以下名为”vistors”的表,该表具有如下 epoch −
mysql> Create table visitors(userid int not null, name varchar(20), epoch int NOT NULL); Query OK, 0 rows affected (0.42 sec) mysql> Insert into visitors Values(1, 'Gaurav', 1358658942); Query OK, 1 row affected (0.04 sec) mysql> Insert into visitors Values(2, 'Raman', 1358659585); Query OK, 1 row affected (0.04 sec) mysql> Select userid, name, FROM_UNIXTIME(epoch) from visitors; +--------+--------+----------------------+ | userid | name | FROM_UNIXTIME(epoch) | +--------+--------+----------------------+ | 1 | Gaurav | 2013-07-24 16:05:42 | | 2 | Raman | 2013-07-24 16:16:25 | +--------+--------+----------------------+ 2 rows in set (0.00 sec)
广告