开发者

MYSQL DateTime - PHP Conversion

开发者 https://www.devze.com 2023-03-31 11:40 出处:网络
I have a MYSQL datetime that looks like this - 2011-08-28 12:39:21 I need (in PHP) to see if the time is within 3 minutes of the current time.

I have a MYSQL datetime that looks like this - 2011-08-28 12:39:21

I need (in PHP) to see if the time is within 3 minutes of the current time. I know how to do it in MySQL like 'BETWEEN NOW()-INTERVAL 3 MINUTE AND NOW()', But in this case I need to do it in PHP.

Advice on how to findout if the datetime is within the last 3 min开发者_高级运维utes or now?

cheers


Use this function:

if (strtotime($datetime) >= time() - 180) {
    // within last three minutes or later
}


This is not possible.

if (strtotime($datetime) >= time() - 180) {
    // within last three minutes or later
}

if you dont upgrade from your server MYSQL 5.2 and plus your dont fixed this.

0

精彩评论

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