这段代码可以使用
$date = "12/09/2016";
$sql = "SELECT * FROM someTable.forum_posts_queue where post_owner='admin' and post_create_time = '".$date."' order by post_id desc limit 0,1";
但是,我想将日期设置为变量并将其作为字符串传递
$date = date("m/d/Y");
$sql = "SELECT * FROM someTable.forum_posts_queue where post_owner='admin' and post_create_time = '".$date."' order by post_id desc limit 0,1";
这不会像上面那样读取日期,也不理解查询。
答案 0 :(得分:1)
使用
$date = date("Y-m-d");
应该解决您的问题(假设" post_create_time"字段的类型是DATE,DATETIME或TIMESTAMP)。