MysQL通过查询获取时间


MysQL Get Time via Query

"注册"行中的时间存储如下:"1427538785"所以我不能使用这种方法:WHERE DATE(Signup) = DATE(NOW())

但需要查询今天的注册时间。。

知道怎么解决这个问题吗?

您需要from_unixtime

mysql> select from_unixtime('1427538785','%Y-%m-%d');
+----------------------------------------+
| from_unixtime('1427538785','%Y-%m-%d') |
+----------------------------------------+
| 2015-03-28                             |
+----------------------------------------+
1 row in set (0.00 sec)

所以查询将是

WHERE from_unixtime(Signup,'%Y-%m-%d') = curdate();
WHERE DATE(FROM_UNIXTIME(Signup)) = curdate()