$currentDate = time() - $printDate; //print date is a timestamp in mysql
$numberDays = floor($currentDate/(606024));
echo "number of days: $numberDays </br>";
$editedDate = date("d ", $numberDays);
echo "edited date: $editedDate";
这是我的输出:
number of days: 15562
edited date: 31
number of days: 15562
edited date: 31
number of days: 15562
edited date: 31
这给了我 15562 和 31,所以我在这里遗漏了什么吗?我只需要打印出天的差异
编辑:如果正在搜索此问题的任何人也碰巧遇到它,那么这是有效的最终输出:
$currentDate = time();
echo "Current Time:";
echo $currentDate;
echo "</br>";
$editedPrintDate = strtotime($printDate);
echo "Print Date:";
echo $editedPrintDate;
echo "</br>";
$numberDays = floor(abs($currentDate - $editedPrintDate)/60/60/24);
echo "Number of Days:";
echo floor($numberDays);
echo "</br>";