可能重复:
在PHP 中减去日期
我有两个Unix时间戳,如何计算它们之间的总天数?
$timestamp1 = x;
$timestamp2 = y;
$days_elapsed = floor(($timestamp2 - $timestamp1)/86400);
echo $days_elapsed;
将它们转换为UNIX时间戳(如果它们还没有(,然后只转换
$diff = abs($timestamp1 - $timestamp2);
$days = (int) ($diff / 60 / 60 / 24);
应该这样做:$days = (strtotime($timestamp1)-strtotime($timestamp2))/(60*60*24);
这个代码应该能完成
$numDays = abs($timeOne - $timeTwo)/60/60/24;