RE: [PHP] time question.

From: Date: Fri, 26 Jul 2002 17:27:52 +0000
Subject: RE: [PHP] time question.
Groups: php.general 
Request: Send a blank email to php-general+get-109827@lists.php.net to get a copy of this message
Thanks to all for the reply, Sorry it wasn't very detailed, What I am doing is writing the time to a time field in mysql when a user is editing an order. Then when another admin user goes to pick the order, if a time greater than 00:00:00 exists, and that time is less than 10 minutes from the time in the database, he/she will not be able to edit the order. If it is greater than 10 minutes I will assume a connection was lost etc and allow the admin to pick the order. I would like to be able to check that in the query, so if what you recommended will work I'll try that first. Thanks, Steve. -----Original Message----- From: 1LT John W. Holmes [mailto:holmes072000@charter.net] Sent: Friday, July 26, 2002 12:42 PM To: Steve Bradwell; php-general@lists.php.net Subject: Re: [PHP] time question. > How do I compare time in php? > > Eg. If I have a mysql time field I retrieve stored in $result[0][0] how do I > say : > > if (($result[0][0] > $result[0][0] plus ten minutes) && ($result[0][0] > > '00:00:00')){ MySQL and PHP timestamps are in different formats. MySQL uses YYYYMMDDHHMMSS and PHP uses a unix timestamp, the number of seconds since January 1st, 1970. You can use UNIXTIMESTAMP(your_column) in your query to get a PHP style unix timestamp. Although, if you explain what you are trying to do a little better, you could probably do the comparisons a lot easier in your query and not involve PHP at all. SELECT * FROM your_table WHERE your_column > your_column + INTERVAL 10 MINUTE AND your_column != 0 That looks equivilent to what you're trying to do in PHP. You might have to say your_column+0 != 0 to get your_column as an integer and not a string. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#109827) next »