1、将日期格式转换成时间戳查询
SELECT yx_user. NAME AS 用户名, yx_space_podcast.content AS 发布内容, FROM_UNIXTIME( yx_space_podcast.created_at ) AS 发布时间, yx_location. NAME AS 城市, yx_space_podcast.user_id AS 用户ID FROM yx_space_podcast LEFT JOIN yx_user ON yx_user.id = yx_space_podcast.user_id LEFT JOIN yx_location ON yx_user.location_id = yx_location.id WHERE yx_space_podcast.created_at > UNIX_TIMESTAMP('2019-04-01 00:00:00') AND yx_space_podcast.created_at < UNIX_TIMESTAMP('2019-04-27 00:00:00') AND yx_space_podcast.is_delete = 0;
上面查询用到了两个函数
FROM_UNIXTIME: 将时间戳转换成日期格式 默认是2019-04-28 00:00:00
UNIX_TIMESTAMP: 将日期转换成时间戳格式
来源:https://www.cnblogs.com/webclz/p/10782693.html