how to compare two timestamp values from mysql with php
I have a db with time stamp开发者_开发问答 values in this format: 0000-00-00 00:00:00
When I add this to the db I add a minutes to the current time. Now I need to check if the current time has passed the value added to the db. (x minutes passed)..
example add to db:
$time = strtotime ("+2 minutes");
$mysql_time = gmdate("Y-m-d H:i:s", $time);
Then I get that value from the db. And need to compare current time with that value. I used to use unix values like this: if(time() <= $unix_time){...}
but now, I want to compare timestamp values instead.. Something like if(timeMysql() <= $mysql_time){..}
There's a function UNIX_TIMESTAMP that'll convert 0000-00-00 00:00:00
formatted value to linux timestamp integer.
You can use this: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp
精彩评论