PHP - Calculate time between dates

JeremyLKnauff

New Member
would like to learn how I can calculate the time between two dates. I am working on an Unlock user functionality and the following is what I have:\[code\]// get offender's username from session $username = $_SESSION['UserName']; require_once('./connections/mysql.php'); $checklockoutexpiration = mysqli_query($conn,"SELECT IsLockedOut, LastLockoutDate FROM users WHERE UserName = '$username' Limit 1") or die($dataaccess_error); if(mysqli_num_rows($checklockoutexpiration) == 1) { $row = mysqli_fetch_array($checklockoutexpiration); $islockedout = $row['IsLockedOut']; $lastlockoutdate = $row['LastLockoutDate']; } if(**$islockedout == 1 && $lastlockoutdate + LOCKOUT_DURATION_IN_MINUTES < getdate()**) { // unlock user } \[/code\]The lockout date is in the database in a form of NOW() and looks like 2010-10-13 13:01:05. I assume it is server time which at the moment is my local development machine. QUESTION: How can I do the bold line in the code.In asp.net I would do something like: \[code\]// if lockout datetime + lockout duration is less than datetime now if (usrInfo != null && usrInfo.IsLockedOut && usrInfo.LastLockoutDate.ToUniversalTime().AddMinutes(passwordAttemptLockoutDuration) < DateTime.UtcNow) { // then automatically Unlock user usrInfo.UnlockUser(); } \[/code\]Could some one please show me how this is done?Thank you!
 
Back
Top