shlomikalfa Posted May 25, 2008 Share Posted May 25, 2008 hey there, i've been wandering why doesn't my SQL call not working... it's suppose to delete all entries which their `TimeStamp` is older then 180 seconds the "1211720372" is out-putted by the: (time()-180) - In php, just a couple of seconds ago... Also the MySQL DB column `TimeStamp` is updated by latest time stamp. DELETE FROM `captchas` WHERE `TimeStamp` <= "1211720372" Another Q. i have is: i have a MySQL DB column `TimeStamp` which is set to default to the current time_stamp. Does that `TimeStamp` column is "renewed" on every change to the table [uPDATE, SELECT ETC...]. Link to comment https://forums.phpfreaks.com/topic/107180-solved-performing-mysql-calls-based-on-current-timestamp-and-a-mysql-timestamp/ Share on other sites More sharing options...
BlueSkyIS Posted May 25, 2008 Share Posted May 25, 2008 need to see code for the first bit. Does that `TimeStamp` column is "renewed" on every change to the table [uPDATE, SELECT ETC...]. by default, timestamp updates on insert or update. not select. Link to comment https://forums.phpfreaks.com/topic/107180-solved-performing-mysql-calls-based-on-current-timestamp-and-a-mysql-timestamp/#findComment-549529 Share on other sites More sharing options...
shlomikalfa Posted May 25, 2008 Author Share Posted May 25, 2008 THANKS A LOT !!! that's one out of 2... I think that the problem is that i'm trying to compare a string timestamp with a PHP INT timestamp... MySQL timestamp = 2008-05-25 17:19:49 PHP generated time()-180 = 1211726264 maybe if i could create through MySQL a similar timestamp it'll work as i want it to... Link to comment https://forums.phpfreaks.com/topic/107180-solved-performing-mysql-calls-based-on-current-timestamp-and-a-mysql-timestamp/#findComment-549543 Share on other sites More sharing options...
shlomikalfa Posted May 25, 2008 Author Share Posted May 25, 2008 oky, it was correct... that's how it should be done: UNIX_TIMESTAMP(`TimeStamp`) -. this will transform a TimeStamp value [str date: ][MySQL] into the same format as the time() function timestamp in PHP. MySQL: UNIX_TIMESTAMP(2008-05-25 17:19:49) -->> 1211726264 PHP: time() -->> 1211726264 now you can compare these two... Link to comment https://forums.phpfreaks.com/topic/107180-solved-performing-mysql-calls-based-on-current-timestamp-and-a-mysql-timestamp/#findComment-549559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.