Jump to content

[SOLVED] Performing MySQL calls based on current TimeStamp and a MySQL TimeStamp.


shlomikalfa

Recommended Posts

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...].

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...

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.