我的问题如下:

当执行DoExpressCheckout()时,我必须将一些数据保存到数据库中,包括当前时间+ X时间

数据库字段的类型设置为“ datetime”

我以这种方式使用strtotime函数

date_default_timezone_set('Europe/Rome');

$currentTime = date("Y-m-d");

$expected = date('Y-m-d',strtotime($currentTime.'+ 7 days'));

echo $expected;

$sql = "INSERT INTO acquisti (durata,prezzi,expectedtime) VALUES (".$str.",".$resArray['AMT'].",".$expected.")";
echo $sql;
mysql_query($sql) or die("Errore di inserimento");


在这里我有两个问题:

1)将$ expected变量放入Expectedtime字段时,查询总是返回我错误
2)如果我手动把它放进去(只是想尝试一下我是否是愚蠢的),它会写信给我(我已经启用了ALLOW_INVALID_DATES)

有什么建议么?

非常感谢

最佳答案

您的字段类型为“ datetime”,但您仅使用INSERT查询发送日期。

您需要使用date('Y-m-d H:i:s')代替date('Y-m-d'),或者如果仅需要日期,则将字段的类型更改为date。

10-06 12:37
查看更多