开发者

how to compare two timestamp values from mysql with php

开发者 https://www.devze.com 2023-02-01 18:52 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消