$lastLoginTime = date("Ymd H:i:s"); //最后一次登录,登录时将存储在数据库中
假设上次登录是:2012-05-11 07:57:46
当前时间是:$current_time = date("Ymd H:i:s")
$diff_seconds = strtotime($current_time) - strtotime($lastLoginTime);
$diff_weeks = floor($diff_seconds/604800);
$diff_seconds -= $diff_weeks * 604800;
$diff_days = floor($diff_seconds/86400);
$diff_seconds -= $diff_days * 86400;
$diff_hours = floor($diff_seconds/3600);
$diff_seconds -= $diff_hours * 3600;
$diff_minutes = floor($diff_seconds/60);
$diff_seconds -= $diff_minutes * 60;
echo "You last logged in $diff_weeks weeks, $diff_days days, ";
echo "$diff_hours hours, $diff_minutes minutes, and $diff_seconds minutes ago.";
错误的输出......!:-(