【发布时间】:2014-06-05 09:23:33
【问题描述】:
如何在 php 中将 INT 转换为日期,然后在 mysql 表中找到这个日期?
假设我想转换
$month = (int)$_GET['month'];
$month = 42014 ;//This means 04th month in 2014 year
$month = 04-2014; // I want this
然后在 mysql 表中找到它
$query=mysql_query("SELECT id FROM matches WHERE date=$month");// This need to select
// all data that is
// created in 04th month
// of 2014 year .
echo "Thanks :)";
【问题讨论】:
-
var_dump($_GET['month']);是什么? -
string(6) "042014" // 但也会出现一些其他错误
-
对于
42014日期值,您可以使用WHERE DATE_FORMAT(date,'%m%Y')='$month'