The condition you want to compare is if the current date/time is greater than the date/time in the record plus 90 minutes. So, do something like this:
// Get the current date/time. $now = new DateTime(); // Create a DateTime object based on the date/time in the record. Assume $datetimeRecord contains the date/time value from the record in string format. $deadline = new DateTime($datetimeRecord); // Add 90 minutes to the time the record started to be edited. $deadline->modify('+90 minutes'); // Compare the two date/times. if($now->format('Y-m-d H:i:s') > $deadline->format('Y-m-d H:i:s')): // Editing time has expired. // Update record to clear date/time. // Allow new user to edit. endif; Of course another problem you'll need to tackle is if User A starts editing the record and walks away leaving the screen where its at. 91 minutes later, User A comes back and saves their changes. Their editing time has already expired. What you might need to do is put a similar check in the PHP script that saves the data to make sure the editing time hasn't expired yet. If it has, don't save the data (as User B may have already come along and updated the record). You could take User A back to the edit page and reload the data for the record and allow them to start editing again. Hope that helps! Let me know if you have any further questions. * Jim Mullen* iDimensionz <http://www.iDimensionz.com/> Professional web site programming and design. Affordable web site hosting. Follow iDimensionz on Twitter <http://twitter.com/iDimensionz> and Facebook <http://www.facebook.com/pages/iDimensionz/63769662255>. On 9/3/10 11:25 AM, pirate_lenny wrote: > > I want to write a check-in/check-out feature for editing content on my > site. I want users to be able to check out pages so that the page > can't be edited by anyone else while they are editing. I can't rely on > them to always check records back in so I want to write a script that > will query when they checked it out and then if it's a certain amount > of time later (like 90 minutes or something), to check it back in. > > So, my plan is that when the user hits the "check out" button, it > writes a check out timestamp to that record in the DB. But, I want > their editing time to end after 90 minutes. So, if another user hits > the page within that 90 minutes, the check out button won't show. But > outside of that 90 minutes, the button will show and the check out > time will be erased. > > How do I write a script that will check if a datetime field is 90 > minutes later? > > [Non-text portions of this message have been removed]