作者:mobiledu2502900677 | 来源:互联网 | 2023-09-18 19:10
元素:"added_date" => date("Y-m-d H:i:s")
,存储在2019-10-30 21:25:57
之类的数据库中,我想计算自从上一篇文章被编辑以来的几天前;就我而言,大约要7天前。
if ($_POST) {
extract($_POST);
$dataupdate = array(
"email" => $email,"contactname" => $contactname,"submissions" => $submissions,"ispublish" => $ispublish,"added_date" => date("Y-m-d H:i:s"),);
$ins = $db->insert($dataupdate,PREFIX . "submissions");
$_SESSION["add_message"] = 1;
?>
}
?>
您可以使用DateTime。 https://www.php.net/manual/en/datetime.diff.php
页面示例:
$datetime1 = new DateTime('2019-10-30 21:25:57');
$datetime2 = new DateTime('2019-11-31 21:25:57');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days');