2011-06-25 16 views
0

変数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); 

        } 

       } 

答えて

1

$ diffは秒です。 $ diff = $ diff/60に分けて分単位に変換することができます。

関連する問題