Thread: php time?
View Single Post
Old 06-10-2009, 07:18 PM   #4 (permalink)
Village Idiot
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by DizzyD View Post
Thanks for the quick response. The database is set to automatically set the time/date when the entry is made (CURRENT_TIMESTAMP). So the format is set like so:

2009-06-09 20:54:13

So yes I pull it as a string,

$row['time'] displays "2009-06-09 20:54:13"

So i need to get the current time in that same format I would assume, then find the difference of the 2. If it's 8 or more, perform action.
What data type is it? I would assume timestamp if that is the default value. If that is corrent, that means that you are getting the a formatted timestamp opposed to a string. Have a query something like this
Code:
SELECT * FROM db WHERE DATESUB(CURDATE(),INTERVAL 8 HOURS)>=insert_time
Anything that query returns will be more than eight hours old. insert_time being the column name of your timestamp. This code is not tested, but should work.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
DizzyD (06-10-2009)