我需要在DB中检查日期+ 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
我的错误在哪里?
答案 0 :(得分:4)
UNIX_TIMESTAMP("date")
应为UNIX_TIMESTAMP(date)
。在那里有引号,它试图将文字字符串“date”转换为时间戳。
答案 1 :(得分:2)
从查询中的"
函数中删除双引号unix_timestamp
。它应该是:
SELECT UNIX_TIMESTAMP(date) AS date FROM followform WHERE id = "28"