警告:date() 期望参数 2 很长,给定字符串

Warning: date() expects parameter 2 to be long, string given

一个错误:

Warning: date() expects parameter 2 to be long

这是回发 php 脚本部分,

$conv_time = time();
$click_time_to_date = new DateTime(date('Y-m-d h:i:s', $mysql['click_time']));
$conv_time_to_date = new DateTime(date('Y-m-d h:i:s', $conv_time));
$diff = $click_time_to_date->diff($conv_time_to_date);
$mysql['time_difference'] =  $db->real_escape_string($diff->d.' days, '.$diff->h.' hours, '.$diff->i.' min and '.$diff->s.' sec');
$mysql['conv_time'] = $db->real_escape_string($conv_time);
$mysql['ip'] = $db->real_escape_string($_SERVER['HTTP_X_FORWARDED_FOR']);
$mysql['user_agent'] = $db->real_escape_string($_SERVER['HTTP_USER_AGENT']);

您的 click_time 字段可能是 DATETIME 类型,并且 date() 期望第二个参数是时间戳 (long)。

尝试将第 2 行替换为:

$click_time_to_date = new DateTime($mysql['click_time']);

或者确保您的 click_time 字段的类型为 TIMESTAMP