在几分钟内找出变量timeRemaining的正确公式是什么。
$lockDate = $row['lockDate'];
$currentDateTime = time();
// Find out if user is locked out of their account
if (($lockDate != "0000-00-00 00:00:00") && strtotime($lockDate) < $currentDateTime) {
$lockDate = strtotime($lockDate);
$diff = $currentDateTime - $lockDate;
echo $diff;
// Take minutes and perform tasks
if ($diff <= 600) {
// Calculate time remaining
$timeRemaining = 10 - $diff;
// Account locked error
$errors = true;
$message = "Your account is currently locked, we appologize for the inconvienence. You must wait " .$timeRemaining." minutes before you can log in again!";
$output = array('errorsExist' => $errors, 'message' => $message);
} else {
// Clear the lock
// $query = "UPDATE manager_users_hacking SET lockDate = NULL, hackerIPAddress = NULL, failedLogins = 0 WHERE userID = '".$userID."'";
$result = mysqli_query($dbc,$query);
}
}
答案 0 :(得分:1)
$ diff是几秒钟。您可以通过除以60来转换为分钟。$ diff = $ diff / 60。