-2

我需要使用正确的日期从数据库中检查日期 + 1 个月。我尝试:

$todayDate = date("Y-m-d");
$dateOneMonthAdded = strtotime(date("Y-m-d", strtotime($todayDate)) . "+1 month");

$result = mysql_query('SELECT UNIX_TIMESTAMP("date") AS date FROM followform WHERE id = "28"') or die(mysql_error());  
$date = mysql_fetch_assoc($result);

if ($dateOneMonthAdded == $date['date']) echo 'nice';

但是 $date['date'] == 0

如果我使用 -mysql_query('SELECT date FROM followform WHERE id = "28"')

$date['date'] == 2012-08-13

我的错误在哪里?

4

2 回答 2

4

UNIX_TIMESTAMP("date")应该是UNIX_TIMESTAMP(date)。使用引号,它试图将文字字符串“日期”转换为时间戳。

于 2012-08-13T15:10:34.907 回答
2

"unix_timestamp查询中的函数中删除双引号。它应该是:

SELECT UNIX_TIMESTAMP(date) AS date FROM followform WHERE id = "28"
于 2012-08-13T15:11:19.807 回答