Home >Backend Development >PHP Tutorial >php mysql 查询日期怎么写?

php mysql 查询日期怎么写?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:26:081121browse

例如

mysql_query("select * from 表 where 时间字段=今天 and ID='$TID'",$conn);

时间字段存储的格式是2015-09-17 06:46:53  

比如我只想查询  2015-09-17 =2015-09-17 

需要把时间字段转换成ymd  今天的时间也需要转换长ymd


这怎么弄?迷糊啊  求帮助啊 


回复讨论(解决方案)

不知道这样算不算正确的  请大神来帮忙哈

mysql_query("select * from 表 where date_format(时间字段,'%Y-%m-%d')=curdate() and ID='$TID'",$conn);

没搞明白curdate()这个返回的是不是ymd

试一下不就知道了吗。 select curdate();查询当前日期

用模糊查询吧

mysql_query("select * from 表 where 时间字段 LIKE %" . date('Y-m-d',time()) . "% and ID='$TID'",$conn);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn