1、UNIX时间戳转换为日期用函数: FROM_UNIXTIME()
select FROM_UNIXTIME(1156219870);
输出:2006-08-22 12:11:10
2、日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP()
Select UNIX_TIMESTAMP('2006-11-04 12:23:00');
输出:1162614180
$sql=”select * from message Where DATE_FORMAT(FROM_UNIXTIME(chattime),’%Y-%m-%d’) = DATE_FORMAT(NOW(),’%Y-%m-%d’) order by id desc”;